trailwalker Posted February 23, 2010 Share Posted February 23, 2010 Hello all. I have the following lines in a script to save data to a text file. If the file does not exist, the file is created successfully. Also, if the file exists, another function using the same FileOpen but with "0" mode for read only successfully retrieves the data from the file. However, if the file already exists, and the overwrite mode is specified, it errors out. In desperation, I also tried using FileDelete first to remove it and then create it again and this also receives an error. $file_msg = FileOpen($bfile, 2) If $file_msg = -1 Then MsgBox(16, "Error 106", "We could not save the file to this location.") Return 0 Else $write = FileWrite($file_msg, $data_to_write) If $write = 0 Then MsgBox(16, "Error 107", "We could not save the data to the file selected.") EndIf ; close the file FileClose($file_msg) EndIf I have also tried using the WinAPI_CreateFile, etc and got the same error. Also moved the file being overwritten to the shared docs on the computer and it still wouldn't overwrite. Im on XP SP3 and cannot for the life of me figure this one out! Again, keep in mind that when the same code is run and the file doesn't exist yet, it is created with the data specified above. Thanks! Aaron Link to comment Share on other sites More sharing options...
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 account
Already have an account? Sign in here.Sign In Now