mibuso.com

Microsoft Business Solutions online community
It is currently Fri May 24, 2013 8:22 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [Solved] Moving file to another folder
PostPosted: Tue Sep 21, 2010 4:56 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
hi, how to move another file from folder A to Folder B ?
like cut and paste
thanks


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 5:45 am 
Offline

Joined: Tue Jun 16, 2009 10:18 am
Posts: 91
Location: Vadodara
Country: India (in)
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,

Kashyap


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 6:09 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
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 this
Code: Select all
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


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 6:18 am 
Offline

Joined: Tue Apr 27, 2010 8:08 am
Posts: 10
Country: China (cn)
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 this
Code: Select all
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');


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 6:24 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
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 this
Code: Select all
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)


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 6:33 am 
Offline

Joined: Tue Apr 27, 2010 8:08 am
Posts: 10
Country: China (cn)
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);


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 6:35 am 
Offline

Joined: Tue Jun 16, 2009 10:18 am
Posts: 91
Location: Vadodara
Country: India (in)
Quote:
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...
Code: Select all
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,

Kashyap


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 6:37 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Thu Oct 16, 2003 8:50 am
Posts: 12265
Location: Brno
Country: Czech Republic (cz)
You can use this:
Quote:
CREATE(Shell);
Path := Shell.GetParentFolderName(FullFileName)+'\';
FileName := Shell.GetFileName(FullFileName);


Where Shell is automation of type "'Windows Script Host Object Model'.FileSystemObject".

_________________
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.


Top
 Profile E-mail WWW  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 8:01 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
kash387 wrote:
Quote:
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...
Code: Select all
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???


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 8:01 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
kine wrote:
You can use this:
Quote:
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 me

Code: Select all
CREATE(Shells);
Path := Shells.GetParentFolderName(FullFileName) +'\';
FileName := Shells.GetFileName(FullFileName);
MESSAGE('%1 - %2 = %3',Path,FileName,FullFileName);


but in message box only appear --> \ - =


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 8:07 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
it works
my full code is like this
Code: Select all
CREATE(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 deleted


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 8:45 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
done already
just like this

Code: Select all
CREATE(Shells);
Path := Shells.GetParentFolderName(FileName) +'\';
FileTxt := Shells.GetFileName(FileName);
FILE.COPY(FileName,'C:\' +'\' + FileTxt);
JFFile.CLOSE();
FILE.ERASE(FileName);


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 10:47 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
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...


Top
 Profile E-mail  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 10:54 am 
Offline

Joined: Thu Oct 30, 2008 10:38 am
Posts: 987
Location: Earth
Country: Netherlands (nl)
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|
|MCBMSS: 5.0 intro|MCTS:NAV09 839..841|JetReports© Certified Specialist|
|Dynamics Anywhere: Mobile Business Solutions|


Top
 Profile  
 
 Post subject: Re: Moving file to another folder
PostPosted: Tue Sep 21, 2010 11:02 am 
Offline

Joined: Fri Jun 11, 2010 5:32 am
Posts: 223
Country: Holy See (Vatican City State) (va)
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 name


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: