FILE.COPY(FromName,ToName); // FromName is your file name with current location (path), ToName is the new location with File name
FILE.ERASE(From);// This will erase your file with previous location...
So your file will be cut and paste on new folder...!!!!
like you said
i add code like this
FILE.COPY(FileName,'C:\');
FILE.ERASE(FileName);
but it was said
the operating system cannot find the directory specified for the file C:\
please check that the drive,directory and file names are correct
FILE.COPY(FromName,ToName); // FromName is your file name with current location (path), ToName is the new location with File name
FILE.ERASE(From);// This will erase your file with previous location...
So your file will be cut and paste on new folder...!!!!
like you said
i add code like this
FILE.COPY(FileName,'C:\');
FILE.ERASE(FileName);
but it was said
the operating system cannot find the directory specified for the file C:\
please check that the drive,directory and file names are correct
you must specify the file path completely.
copy('c:\a.txt','c:\b.txt');
FILE.COPY(FromName,ToName); // FromName is your file name with current location (path), ToName is the new location with File name
FILE.ERASE(From);// This will erase your file with previous location...
So your file will be cut and paste on new folder...!!!!
like you said
i add code like this
FILE.COPY(FileName,'C:\');
FILE.ERASE(FileName);
but it was said
the operating system cannot find the directory specified for the file C:\
please check that the drive,directory and file names are correct
you must specify the file path completely.
copy('c:\a.txt','c:\b.txt');
but how can get that a.txt
because fileName --> path + file name (example : C:\a.txt)
but how can get that a.txt
because fileName --> path + file name (example : C:\a.txt)
that you have to write codes to read .txt file from that folder...
for that you can use File (record) concept of NAV....
like...
RecFile.SETRANGE(Path,yourpath); // your path will be like, c:\abc like that abc is folder...
RecFile.SETRANGE("Is a file",TRUE);
if RecFile.findfirst then repeat
// here do coding that you will get file that is having .txt extension
// then go for those two lines that i mentioned in first post
// your complete code will be in this loop only...!!!
until RecFile.next = 0;
this is what i have done for one of my client...!!!
but how can get that a.txt
because fileName --> path + file name (example : C:\a.txt)
that you have to write codes to read .txt file from that folder...
for that you can use File (record) concept of NAV....
like...
RecFile.SETRANGE(Path,yourpath); // your path will be like, c:\abc like that abc is folder...
RecFile.SETRANGE("Is a file",TRUE);
if RecFile.findfirst then repeat
// here do coding that you will get file that is having .txt extension
// then go for those two lines that i mentioned in first post
// your complete code will be in this loop only...!!!
until RecFile.next = 0;
this is what i have done for one of my client...!!!
The path is undefined, so the user will select the file from any folder
and recFile is table???
after using automation
my code in another form is error
like i setup path for export is C:\Folder Name
but after i export it... it is not C:\Folder Name\File Name.txt
but C:\Folder NameFileName.txt
is it because this automation?
please help...
your code in the previous post did not include the path.
And after the copy you should check if the copy is complete before erasing the file.
something like a do until copycomplete;
|Pressing F1 is so much faster than opening your browser| |To-Increase|
your code in the previous post did not include the path.
And after the copy you should check if the copy is complete before erasing the file.
something like a do until copycomplete;
no.... i have 2 files
1st.... import (the code i show here) -> it successfuly
but in another form... while i exported it... it become an error
because it doesn't read as a path, but a file name
This is an exception to running a routine on the nas using movefile.
This message is for C/AL programmers:
An exception was raised in method MoveFile. The OLE control or Automation server has returned error (HRESULT) -2147352567.
The component did not provide the exception description.
OnPostDataport()
CurrFile.CLOSE; //Close The Imported File
SavedFileName := FORMAT(WORKDATE,0,'<Year4>'+'-'+'<Month Text,3>'+'-'+'<Day,2>'+'-'+DELCHR((FORMAT(TIME)),'=',':'))+'.txt'; //Create a New Filename for Imported File
FILE.COPY(CurrDataport.FILENAME,FilePath+SavedFileName); //Copy File To New Location
ERASE(CurrDataport.FILENAME);//Delete Original File
GLSetup.GET;
SFolder.SETRANGE(Path,GLSetup."Import Path" + 'Item\');
SFolder.SETRANGE("Is a file",TRUE);
IF ISCLEAR(Shells) THEN
CREATE(Shells);
IF SFolder.FINDSET THEN
REPEAT
SFile.TEXTMODE(TRUE);
SFile.WRITEMODE(FALSE);
SFile.OPEN(GLSetup."Import Path" + 'Item\' + SFolder.Name);
.
.
.
.
//Move File To History Folder
Path := Shells.GetParentFolderName(GLSetup."Import Path" + 'Item\' + SFolder.Name);
FileTxt := Shells.GetFileName(GLSetup."Import Path" + 'Item\' + SFolder.Name);
FILE.COPY(GLSetup."Import Path" + 'Item\' + SFolder.Name,GLSetup."History Path" + 'Item\' + FileTxt);
SFile.CLOSE();
FILE.ERASE(GLSetup."Import Path" + 'Item\' + SFolder.Name);
UNTIL SFolder.NEXT =0;
if execute this code unit is just fine
but if execute using webservice from C#,it will prompt me an error as in attachment
it was said about I/O Exception
is it about my shells?
Answers
Use the concept of File.
FILE.COPY(FromName,ToName); // FromName is your file name with current location (path), ToName is the new location with File name
FILE.ERASE(From);// This will erase your file with previous location...
So your file will be cut and paste on new folder...!!!!
Kashyap
like you said
i add code like this
but it was said
the operating system cannot find the directory specified for the file C:\
please check that the drive,directory and file names are correct
you must specify the file path completely.
copy('c:\a.txt','c:\b.txt');
but how can get that a.txt
because fileName --> path + file name (example : C:\a.txt)
It will open a window and return the complete path of which file you selected.
ReturnParth:=FileDialog.OpenFile('',DefaultPath,0,'',0);
that you have to write codes to read .txt file from that folder...
for that you can use File (record) concept of NAV....
like...
this is what i have done for one of my client...!!!
Kashyap
Where Shell is automation of type "'Windows Script Host Object Model'.FileSystemObject".
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
The path is undefined, so the user will select the file from any folder
and recFile is table???
i'm using this code like you gave me
but in message box only appear --> \ - =
my full code is like this
but it was said that the file is in used, and cannot be deleted
just like this
my code in another form is error
like i setup path for export is C:\Folder Name
but after i export it... it is not C:\Folder Name\File Name.txt
but C:\Folder NameFileName.txt
is it because this automation?
please help...
And after the copy you should check if the copy is complete before erasing the file.
something like a do until copycomplete;
|To-Increase|
no.... i have 2 files
1st.... import (the code i show here) -> it successfuly
but in another form... while i exported it... it become an error
because it doesn't read as a path, but a file name
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I have a dataport and i want cut the file when it have been imported. But when i try to do this NAV launch me an error.
OnPostDataItem()
vRutaOrigen := vRutaConfiguracion+'\LOCLPED.TXT';
vRutaDestino := vRutaConfiguracion + '\Historico\LOCLPED.TXT';
FILE.COPY(vRutaOrigen,vRutaDestino);
FILE.ERASE(vRutaOrigen);
Error:
the system can not perform the operation because the file is in use
I have write FILE.ERASE(vRutaOrigen) on PostDataport too but i have the same error. Why??
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Sorry i have written CurrFile.ERASE but i want to write CurrFile.CLOSE
My problem was i had written CurrFile.Close in other trigger. [-X
Thx!!
thanks
This message is for C/AL programmers:
An exception was raised in method MoveFile. The OLE control or Automation server has returned error (HRESULT) -2147352567.
The component did not provide the exception description.
Help ?
CurrFile.CLOSE; //Close The Imported File
SavedFileName := FORMAT(WORKDATE,0,'<Year4>'+'-'+'<Month Text,3>'+'-'+'<Day,2>'+'-'+DELCHR((FORMAT(TIME)),'=',':'))+'.txt'; //Create a New Filename for Imported File
FILE.COPY(CurrDataport.FILENAME,FilePath+SavedFileName); //Copy File To New Location
ERASE(CurrDataport.FILENAME);//Delete Original File
http://www.BiloBeauty.com
http://www.autismspeaks.org
this is my code if execute this code unit is just fine
but if execute using webservice from C#,it will prompt me an error as in attachment
it was said about I/O Exception
is it about my shells?