TheDcoder Posted May 25, 2015 Share Posted May 25, 2015 Hello, This is my (test) code:FileOpen(@ScriptDir & '\' & "Test.txt", 1) $iDeleteResult = FileDelete(@ScriptDir & '\' & "Text.txt") $sDeleteResult = "Pass" If $iDeleteResult = 0 Then $sDeleteResult = "Fail" ConsoleWrite("Result: " & $sDeleteResult & @CRLF)FileOpen does its job (i.e creating a file) but FileDelete fails deleting a simple text file? Thanks in Advance, TD 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...
water Posted May 25, 2015 Share Posted May 25, 2015 Do you want to delete Test.txt or Text.txt? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
TheDcoder Posted May 25, 2015 Author Share Posted May 25, 2015 (edited) Thanks water... Looks like I made a mistake while researching...P.S I had this issue with FileDelete (without the spelling mistake). Edited May 25, 2015 by TheDcoder Opening bracket instead of closing bracket 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...
Starstar Posted May 25, 2015 Share Posted May 25, 2015 FileOpen(@ScriptDir & "\Test.txt", 1) $iDeleteResult = FileDelete(@ScriptDir & '\' & "Test.txt") $sDeleteResult = "Pass" If $iDeleteResult = 0 Then $sDeleteResult = "Fail" ConsoleWrite("Result: " & $sDeleteResult & @CRLF)you are creating Test.txt and you are deleting Text.txt Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
water Posted May 25, 2015 Share Posted May 25, 2015 I'm sure you need to do a FileClose before you can delete a file opened by FileOpen. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
TheDcoder Posted May 25, 2015 Author Share Posted May 25, 2015 @water But my test code works without closing the file handle 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...
Starstar Posted May 25, 2015 Share Posted May 25, 2015 (edited) During file deleting(or any other operation) opened file is not a trouble........But open an other file without closing old one can confuse you........ Edited May 25, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
TheDcoder Posted May 25, 2015 Author Share Posted May 25, 2015 But open an other file without closing old on can confuse youLike this?:FileOpen(@ScriptDir & '\' & "Test1.txt", 1) FileOpen(@ScriptDir & '\' & "Test2.txt", 1) FileOpen(@ScriptDir & '\' & "Test3.txt", 1) $iDeleteResult = FileDelete(@ScriptDir & '\' & "Test3.txt") $sDeleteResult = "Pass" If $iDeleteResult = 0 Then $sDeleteResult = "Fail" ConsoleWrite("Result: " & $sDeleteResult & @CRLF) 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...
water Posted May 25, 2015 Share Posted May 25, 2015 It's good coding practice to close an open file before any other operation.When deleting the file this might not be a problem. But when copying the file there still might be some data in the cache not written to the file. Starstar 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted May 25, 2015 Share Posted May 25, 2015 Like this?:FileOpen(@ScriptDir & '\' & "Test1.txt", 1) FileOpen(@ScriptDir & '\' & "Test2.txt", 1) FileOpen(@ScriptDir & '\' & "Test3.txt", 1) $iDeleteResult = FileDelete(@ScriptDir & '\' & "Test3.txt") $sDeleteResult = "Pass" If $iDeleteResult = 0 Then $sDeleteResult = "Fail" ConsoleWrite("Result: " & $sDeleteResult & @CRLF)Don't think this is a problem for AutoIt.The coder of the script might get confused and hence he might see unexpected results. Starstar 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted May 25, 2015 Share Posted May 25, 2015 (edited) Double post. Edited May 25, 2015 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
TheDcoder Posted May 25, 2015 Author Share Posted May 25, 2015 Oh, I understand now 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