Function Reference


FileDelete

Delete one or more files.

FileDelete ( "filename" )

Parameters

Filename The path of the file(s) to delete. (* and ? wildcards accepted - See Remarks)

Return Value

Success: 1.
Failure: 0 if files are not deleted or do not exist.

Remarks

See FileFindFirstFile() for a discussion about wildcards.

Note: If the "path" passed to FileDelete() is a folder, the files therein will be deleted just as if you had used the *.* mask.

Some file attributes can make the deletion impossible, if this is the case look at FileSetAttrib() to change the attributes of a file.

Related

DirRemove, FileCopy, FileMove, FileRecycle, FileRecycleEmpty

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
Example()
Func  Example()
; Create a constant variable in Local scope of the filepath that will be read/written to.
Local Const $sFilePath= _WinAPI_GetTempFileName (@TempDir )
; Create a temporary file to read data from.
If Not FileWrite ($sFilePath,"This is an example of using FileDelete.")Then
MsgBox ($MB_SYSTEMMODAL,"","An error occurred whilst writing the temporary file.")
Return False
EndIf
; Display the contents of the file passing the filepath to FileRead instead of a handle returned by FileOpen.
MsgBox ($MB_SYSTEMMODAL,"","Contents of the file:"&@CRLF &FileRead ($sFilePath))
; Delete the temporary file.
Local $iDelete= FileDelete ($sFilePath)
; Display a message of whether the file was deleted.
If $iDeleteThen
MsgBox ($MB_SYSTEMMODAL,"","The file was successfuly deleted.")
Else
MsgBox ($MB_SYSTEMMODAL,"","An error occurred whilst deleting the file.")
EndIf
EndFunc ;==>Example

AltStyle によって変換されたページ (->オリジナル) /