Hi all,
maybe stupid question but following scenario:
- I copy a file from pe. desktop to special folder using the navision command file.copy(origfilename,destfilename).
Now sometimes these files (pe. word doc) are still open by user, so he gets a error stating file is in use...so far no problem.
User closes word and want to copy again, but now error that destination file already exists.
This destination file indeed exists, and has 0bytes, and apparantly is held open by the navision client, because i cannot delete it.
Only when we close navision client, this file is being freed up and can be deleted.
Now my question:
- how can i see if a file is in use? (so i don't give the copy command).
- or can i force the destinationfile to be deleted?
Rgds
Benny
Rgds
Benny Giebens
0
Answers
Use this function to determine if a file exists.
[Ok :=] EXISTS(Name)
ERASE
Use this function to erase a file.
[Ok] := ERASE(Name)
You can always do a quick check & erase before you do the copy.
(Example)
If exists ('YourDrive:\YourDirectory\YourFile.txt') then
erase ('YourDrive:\YourDirectory\YourFile.txt');
>>your copy command here
**depending on what's going on with this file you can use F1 help to read about
Currfile.CLOSE; command
We use it on a dataport to move a file from it's original folder to a saved folder once the data has been imported.
here's an example.
Text Constant
FilePath = I:\Internet Data Feed\Completed Import\
OnPostDataport()
http://www.BiloBeauty.com
http://www.autismspeaks.org
i know those commands, no problem there.
But do pe. the following:
Open word document test1.doc in word.
Do in navision: file.copy(test1.doc,copytest1.doc).
You will get an error that file is open.
Close word, and in the same navision session (without closing your navision client), do the copy a second time.
You will get an error that copytest1.doc already exists.
Try to delete copytest1.doc and it will not work.
When you close the navision client, then the file copytest1.doc is deleted.
Thats my problem....
Benny Giebens
If it succeeds, you can close the file and copy it.
indeed simple but working....even did
File.open(...);
File.close;
file.copy(..)
And it works ....stupid but it solves the problem.
Thnx
Benny
Benny Giebens
Is the file automatically closed or there is another method to close it?
Thank you
Quoting on-line help: But File.CLOSE refers to a variable with DataType = File.
Also works in 5.1, that is the version we are using...
Benny Giebens
I tried FILE.CLOSE(FileName) where filename was my text variable in the same way of FILE.ERASE(FileName) without using the variable of type FILE .
Thank you