Java.IO.File.CreateNewFile Method
Creates a new, empty file on the file system according to the path information stored in this file.

Syntax

[Android.Runtime.Register("createNewFile", "()Z", "GetCreateNewFileHandler")]
public virtual bool CreateNewFile ()

Returns

Documentation for this section has not yet been entered.

Exceptions

TypeReason
Java.IO.IOExceptionif it's not possible to create the file.

Remarks

Creates a new, empty file on the file system according to the path information stored in this file. This method returns true if it creates a file, false if the file already existed. Note that it returns false even if the file is not a file (because it's a directory, say).

This method is not generally useful. For creating temporary files, use File.CreateTempFile(string, System.String) instead. For reading/writing files, use Java.IO.FileInputStream, Java.IO.FileOutputStream, or Java.IO.RandomAccessFile, all of which can create files.

Note that this method does not throw IOException if the file already exists, even if it's not a regular file. Callers should always check the return value, and may additionally want to call File.IsFile.

[Android Documentation]

Requirements

Namespace: Java.IO
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1