Bea Posted July 22, 2018 Posted July 22, 2018 Hey i try to make a script which make an text file and than deleat it in a while loop but it dosent deleat until i exit the cript i even cant deleat file manualy why does the script not deleat the file while 1 FileOpen(@ScriptDir & "\TempFile.txt", 1) Sleep(2000) FileDelete("Randome\TempFile.txt") Sleep(2000) WEnd
Moderators JLogan3o13 Posted July 22, 2018 Moderators Posted July 22, 2018 (edited) @Bea A couple of reasons: You create the file @ScriptDir & "\TempFile.txt" but are trying to delete the file "Randome\TempFile.txt" Try doing a FileClose on the file before you delete it Edited July 22, 2018 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
water Posted July 22, 2018 Posted July 22, 2018 Fileclose is missing. 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
Bea Posted July 22, 2018 Author Posted July 22, 2018 2 minutes ago, water said: Fileclose is missing. Thanks but i tried it and it dosent work where is the misstake while 1 FileOpen(@ScriptDir & "\TempFile.txt", 1) FileClose("Randome\TempFile.txt") Sleep(2000) FileDelete("Randome\TempFile.txt") Sleep(2000) WEnd
Moderators JLogan3o13 Posted July 22, 2018 Moderators Posted July 22, 2018 Again, you create a file in the scriptdir called TempFile.txt, then you're trying to delete a file in the ScriptDir under a folder called Randome named TempFile.txt "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Bea Posted July 22, 2018 Author Posted July 22, 2018 2 minutes ago, JLogan3o13 said: Again, you create a file in the scriptdir called TempFile.txt, then you're trying to delete a file in the ScriptDir under a folder called Randome named TempFile.txt Sry i dont get it can you pls write the cod than i understand it, i am sorry
Jfish Posted July 22, 2018 Posted July 22, 2018 Your working with two different locations ... @ScriptDir & "\TempFile.txt" Is different from Randome\TempFile.txt") Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Bea Posted July 22, 2018 Author Posted July 22, 2018 15 minutes ago, Jfish said: Your working with two different locations ... @ScriptDir & "\TempFile.txt" Is different from Randome\TempFile.txt") while 1 FileOpen("Randome\" & "\TempFile.txt", 1) FileClose("Randome\TempFile.txt") Sleep(2000) FileDelete("Randome\TempFile.txt") Sleep(2000) WEnd if done it like this now but it dosent work, why it is different this should be the same where is the problem
Jfish Posted July 22, 2018 Posted July 22, 2018 File open is using two slashes ... you need to keep the path exactly the same. You have Ramdome\\TempFile.txt and Randome\TempFile.txt Those are still not the same. Why are you using "&" ? That concatenates the string and adds the second slash. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Developers Jos Posted July 23, 2018 Developers Posted July 23, 2018 @Bea, The fileopen() returns a filehandle which needs to be used in FileClose(), not the file name! Also remove that double \\ in the first line as mentioned! $fh = FileOpen("Randome" & "\TempFile.txt", 1) FileClose($fh) Sleep(2000) FileDelete("Randome\TempFile.txt") Sleep(2000) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
mikell Posted July 23, 2018 Posted July 23, 2018 You might also define the file path first to avoid errors $file = @scriptdir & "\Randome\TempFile.txt" $fh = FileOpen($file, 1) FileClose($fh) Sleep(2000) FileDelete($file) Sleep(2000)
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