Moving file to another folder

bangswit
Member Posts: 265
hi, how to move another file from folder A to Folder B ?
like cut and paste
thanks
like cut and paste
thanks
1
Answers
-
Hi Bangswit...
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...!!!!Thanks,
Kashyap0 -
kash387 wrote:Hi Bangswit...
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...!!!!
like you said
i add code like thisFILE.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 correct0 -
bangswit wrote:kash387 wrote:Hi Bangswit...
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...!!!!
like you said
i add code like thisFILE.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');0 -
chowyunfat wrote:bangswit wrote:kash387 wrote:Hi Bangswit...
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...!!!!
like you said
i add code like thisFILE.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)0 -
Maybe you can use the function Openfile in codeunit 412.
It will open a window and return the complete path of which file you selected.
ReturnParth:=FileDialog.OpenFile('',DefaultPath,0,'',0);0 -
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...!!!Thanks,
Kashyap0 -
You can use this:CREATE(Shell);
Path := Shell.GetParentFolderName(FullFileName)+'\';
FileName := Shell.GetFileName(FullFileName);
Where Shell is automation of type "'Windows Script Host Object Model'.FileSystemObject".-1 -
kash387 wrote: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???0 -
kine wrote:You can use this:CREATE(Shell);
Path := Shell.GetParentFolderName(FullFileName)+'\';
FileName := Shell.GetFileName(FullFileName);
Where Shell is automation of type "'Windows Script Host Object Model'.FileSystemObject".
i'm using this code like you gave meCREATE(Shells); Path := Shells.GetParentFolderName(FullFileName) +'\'; FileName := Shells.GetFileName(FullFileName); MESSAGE('%1 - %2 = %3',Path,FileName,FullFileName);
but in message box only appear --> \ - =0 -
it works
my full code is like thisCREATE(Shells); Path := Shells.GetParentFolderName(FileName) +'\'; FileTxt := Shells.GetFileName(FileName); FILE.COPY(FileName,'C:\' + FileTxt); FILE.ERASE(FileName);
but it was said that the file is in used, and cannot be deleted0 -
done already
just like thisCREATE(Shells); Path := Shells.GetParentFolderName(FileName) +'\'; FileTxt := Shells.GetFileName(FileName); FILE.COPY(FileName,'C:\' +'\' + FileTxt); JFFile.CLOSE(); FILE.ERASE(FileName);
0 -
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...0 -
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;0 -
Sog wrote: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 name0 -
like i setup path for export is C:\Folder Name0
-
Hi!!
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??0 -
Because the file is still opened in the dataport. You need to do itin OnAfterDataport or close it manually through CurrFile.Close.0
-
kine wrote:Because the file is still opened in the dataport. You need to do itin OnAfterDataport or close it manually through CurrFile.Close.
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!!0 -
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.
Help ?0 -
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 File0 -
hi all
this is my codeGLSetup.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?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions