how can i copy a file??

navision needs to copy a .txt file to another \server\folder\ how can i do that? thanks, trint

Hi, You can use File.COPY(‘c:\data\oldfile’, ‘a:\newfile’) to copy files at different place.

Hi, what Rajesh suggests will work fine… but… If you do this a lot, say in a loop, or an automated process, it may not work. Quite often you will get errors with file locking. If this happens, try to either use the shell command, or better still write a small batch file, and call the batch file from the shell command. On the other hand, if you don’t get locking errors, then do it the way Rajesh suggests.

You could also use Automation “‘Microsoft Scripting Runtime’.FileSystemObject” (win xp).

Can you give me an example using the shell command to call the batch file and also an example bat file

I recommend all of You to start using ‘Microsoft Scripting Runtime’.FileSystemObject when working with files. It’s wery neat. Also it’s not just for XP. It’s in w2k also. Don’t know about older versions.

Example of how to use this? I have defined my var with data type of automation and subtype ‘Microsoft Scripting Runtime’.FileSystemObject. Using this line of code - - - Test.CopyFolder(‘c:\031320300’, ‘d:’); I get an error stating the automation variable has not been instantiated.

Make sure to do a CREATE({variablename}) first. In your case, CREATE(Test).

Jan, Seems to work fine in XP, but not W2k. Is there a different procedure to follow in W2K?

Jan, Pls disregard the previous posting, it works in W2K. Thanks for the help

Lars, can you tell me the advantage of the FileSystemObject? IMHO, most of the Functions i can resolve with the Navision Commands, an in Navision for example the rename Command, i get a bool back, so i can check file locking. Best regreads.

You simply have more functions. Some of the neatest are “GetBaseName”, “GetExtensionName”. You’ll find more info here:


Originally posted by Bastian
…for example the rename Command, i get a bool back, so i can check file locking. …

This works fine most of the time, but if you run it thousands of times in a loop, eventually it will crash. There are still some online interfaces that can only be done with flat files, and in these cases, the rename, copy etc from Navision are not reliable enough for a 24/7 online data link.

You must create a new line: sleep(3000). It works fine with … files import Best regards from bcn.