共用方式為


File.Delete Method

Definition

Deletes the file or directory denoted by this abstract pathname.

[Android.Runtime.Register("delete", "()Z", "GetDeleteHandler")]
public virtual bool Delete ();
[<Android.Runtime.Register("delete", "()Z", "GetDeleteHandler")>]
abstract member Delete : unit -> bool
override this.Delete : unit -> bool

Returns

true if and only if the file or directory is successfully deleted; false otherwise

Attributes

Remarks

Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.

Note that the java.nio.file.Files class defines the java.nio.file.Files#delete(Path) delete method to throw an IOException when a file cannot be deleted. This is useful for error reporting and to diagnose why a file cannot be deleted.

Java documentation for java.io.File.delete().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to