DeleteFile


The DeleteFile method deletes specified file from disk.
C++
long DeleteFile(
  LPSTR FileName               // file name
);
long DeleteFile(
  LPWSTR FileName              // file name
);
BASIC
DeleteFile(
  FileName As Variant          // file name
) As Long

Parameters

FileName
C++
Pointer to buffer containing name of the file (must be NULL terminated).
BASIC
Variant containing name of the file.
Variant must be of String data type; it must not be an array.

Return Values

If the method succeeds, the return value is 0.
If the method fails, the return value is failure code and error code is set. Call GetError to get error code.

Remarks

Method operates on files only - if FileName specifies directory, method returns with error. FileName can be specified as either absolute or relative path.

Unicode version of the method should not be confused with Unicode system calls or Unicode text data. All versions of the method can be used on Unicode and non-Unicode systems depending on your needs. On Unicode systems, however, file is deleted using Unicode version of system function (unless Unicode is disabled with EnableUnicode method). Conversion between ANSI and Unicode is performed internally according to current codepage which can be changed with SetCodePage method. See Unicode Support for more information on Unicode system calls, Unicode methods and Unicode text data.

See Also

File System Operations