FileSystemObject.DeleteFile Method (VB6)

Named Arguments

Yes

Syntax

oFileSysObj.DeleteFile FileSpec [, Force]


oFileSysObj

Use: Required

Data Type: FileSystemObject object

Any object variable returning a FileSystemObject object.


FileSpec

Use: Required

Data Type: String

The name and path of the file or files to delete.


Force

Use: Optional

Data Type: Boolean

If set to True, the read-only flag on a file is ignored and the file deleted.

Description

Permanently removes a given file or files.

Rules at a Glance

  • FileSpec can contain wildcard characters as the final path component.

  • FileSpec can be a relative or absolute path.

  • If any of the files specified for deletion are open, the method fails with a Permission Denied error.

  • The default setting for Force is False.

  • If the specified file or files can't be found, the method fails.

  • If only a filename is used in FileSpec, the application's current drive and directory is assumed.

Programming Tips and Gotchas

  • If an error occurs while deleting more than one file, the DeleteFile method exits immediately, thereby leaving the rest of the files undeleted. There is also no roll-back facility to undo deletions prior to the error.

  • If the user has adequate rights, the source or destination can be a network path or share name. For example:

    DeleteFile "\NTSERV1RootTestmyFile.doc"

  • DeleteFile permanently deletes files; it doesn't move them to the Recycle Bin.

See Also

Kill Statement
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.249.141