Civilian Posted March 19, 2007 Share Posted March 19, 2007 v 3.2.2.0 Not sure if it's a "BUG", but I've noticed that when a file is opened in write mode (1 or 2) using the FileOpen function, even after you close the file, you cannot use FileDelete to remove it. Open it in Read mode only, and it works fine Ex: $file1 = "C:\temp.txt" FileOpen($file1, 1) FileClose($file1) If FileExists($file1) Then FileDelete($file1) EndIf Doesn't work for me even if I use absolute paths, or close the file multiple times, or sleep between FileClose and FileDelete. Doesn't return an error, just won't do what I ask. More than likely, I am just doing something wrong. Thanks, Chris Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 19, 2007 Moderators Share Posted March 19, 2007 (edited) FileClose() needs a handle from FileOpen().$file1 = "C:\temp.txt" $handle = FileOpen($file1, 1) FileClose($handle) If FileExists($file1) Then FileDelete($file1) EndIf Edited March 19, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Civilian Posted March 19, 2007 Author Share Posted March 19, 2007 FileClose() needs a handle from FileOpen(). $file1 = "C:\temp.txt" $handle = FileOpen($file1, 1) FileClose($handle) If FileExists($file1) Then FileDelete($file1) EndIf That's why I'm a noob. Thanks, Chris Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 19, 2007 Moderators Share Posted March 19, 2007 That's why I'm a noob. Thanks,ChrisNo worries... I'll be honest though, you don't see many that have used AutoIt for a while setup a conditional statement for FileDelete(), I guess it isn't really necessary, but I like the idea that you are using conditional statements in just the short snippet you provided, makes me think you will also implement error checking at some time... And that's always a good thing. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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