Bewerken

Share via


FileSystem.Kill(String) Method

Definition

Deletes files from a disk. The My feature gives you better productivity and performance in file I/O operations than Kill. For more information, see FileSystem .

public:
 static void Kill(System::String ^ PathName);
public static void Kill (string PathName);
static member Kill : string -> unit
Public Sub Kill (PathName As String)

Parameters

PathName
String

Required. A string expression that specifies one or more file names to be deleted. PathName can include the directory or folder, and the drive.

Exceptions

Target file(s) open.

Target file(s) not found.

Permission denied.

Examples

This example uses the Kill function to delete a file from a disk.

' Assume TESTFILE is a file containing some data.
Kill("TestFile")   ' Delete file.

' Delete all *.TXT files in current directory.
Kill("*.TXT")

Remarks

Kill supports the use of multiple-character (*) and single-character (?) wildcards to specify multiple files.

Security Note In order to execute, the Kill function requires Read and PathDiscovery flags of FileIOPermission to be granted to the executing code. For more information, see SecurityExceptionCode Access Permissions

Applies to

See also