jsteng Posted January 31, 2019 Share Posted January 31, 2019 (edited) I have a question with regards to FileOpen. Given: A text file @MyDocumentsDir & "\book keeper\logs\logs.txt" is used by another app; but I can open and read it. $FileHandle = FileOpen(@MyDocumentsDir & "\book keeper\logs\logs.txt") The code was successfully executed. something happened afterwards: logs.txt was renamed and a new logs.txt was created, or simply deleted a: Will $FileHandle still point to the renamed file? or b: Will $FileHandle point to the new logs.txt file? or c: Will $FileHandle point to nothing at all? thks Edited January 31, 2019 by jsteng Link to comment Share on other sites More sharing options...
Xandy Posted January 31, 2019 Share Posted January 31, 2019 (edited) Interesting. I don't know, I'd have to start testing it. I'd start by testing: a; If I ever had the time and wanted to know. Edited January 31, 2019 by Xandy TheXman 1 Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
jsteng Posted January 31, 2019 Author Share Posted January 31, 2019 (edited) Lastly, according to documents: Quote The file handle must be closed with the FileClose() function. Considering the file was renamed or deleted, SHOULD I still perform FileClose($FileHandle)??? Edited January 31, 2019 by jsteng Link to comment Share on other sites More sharing options...
Xandy Posted January 31, 2019 Share Posted January 31, 2019 Yes, I would close the file handle in all cases. jsteng 1 Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Xandy Posted January 31, 2019 Share Posted January 31, 2019 If a file handle is returned; It has been allocated and should be freed. (That's how I look at it, but there are other symptoms, like the file staying in use) jsteng 1 Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
TheDcoder Posted January 31, 2019 Share Posted January 31, 2019 50 minutes ago, jsteng said: logs.txt was renamed and a new logs.txt was created, or simply deleted Windows won't allow this as long as there is a program with a open handle to a file... Option C is probably your best bet if you force the operation. Xandy and jsteng 2 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now