ayu_2403 Posted June 13, 2023 Share Posted June 13, 2023 I want to create a file with a name that already exits in a very large folder and check how much time it takes to fail the operation. Using FileWrite will write in the same file. What should i do? Link to comment Share on other sites More sharing options...
Musashi Posted June 13, 2023 Share Posted June 13, 2023 (edited) 35 minutes ago, ayu_2403 said: ... and check how much time it takes to fail the operation Try : #include <FileConstants.au3> Local $sFilePath, $hFileOpen, $hTimer, $fDiff $sFilePath = @ScriptDir & "\example.txt" ; <-- put your filename here $hTimer = TimerInit() $hFileOpen = FileOpen($sFilePath, $FO_READ) If $hFileOpen = -1 Then Exit MsgBox(BitOR(4096, 16), "", "An error occurred when reading the file") EndIf ; Info : Failure=0 if file not opened in writemode, file is read only, or file cannot otherwise be written to. If Not FileWrite($hFileOpen, "some new data") Then $fDiff = TimerDiff($hTimer) FileClose($hFileOpen) Exit MsgBox(BitOR(4096, 16), "", "FileWrite error" & @CRLF & $fDiff & " ms" & @CRLF) EndIf Edited June 13, 2023 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." 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