Jump to content

Create a File with Duplicate Name


Recommended Posts

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 by Musashi

Musashi-C64.png

"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

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

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...