File File Class

Definition

An "abstract" representation of a file system entity identified by a pathname.

[Android.Runtime.Register("java/io/File", ApiSince=1, DoNotGenerateAcw=true)]
public class File : Java.Lang.Object, IDisposable, Java.IO.ISerializable, Java.Lang.IComparable
type File = class
    inherit Object
    interface ISerializable
    interface IJavaObject
    interface IDisposable
    interface IComparable
Inheritance
Attributes
Implements

Remarks

Android platform documentation

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.

Constructors

File(File, String) File(File, String)

Constructs a new file using the specified directory and name.

File(IntPtr, JniHandleOwnership) File(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

File(String) File(String)

Constructs a new file using the specified path.

File(String, String) File(String, String)

Constructs a new File using the specified directory path and file name, placing a path separator between the two.

File(URI) File(URI)

Constructs a new File using the path of the specified URI.

Properties

AbsoluteFile AbsoluteFile

Returns a new file constructed using the absolute path of this file.

AbsolutePath AbsolutePath

Returns the absolute path of this file.

CanonicalFile CanonicalFile

Returns a new file created using the canonical path of this file.

CanonicalPath CanonicalPath

Returns the canonical path of this file.

Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
FreeSpace FreeSpace

Returns the number of free bytes on the partition containing this path.

Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
IsAbsolute IsAbsolute

Indicates if this file's pathname is absolute.

IsDirectory IsDirectory

Indicates if this file represents a directory on the underlying file system.

IsFile IsFile

Indicates if this file represents a file on the underlying file system.

IsHidden IsHidden

Returns whether or not this file is a hidden file as defined by the operating system.

JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
Name Name

Returns the name of the file or directory represented by this file.

Parent Parent

Returns the pathname of the parent of this file.

ParentFile ParentFile

Returns a new file made from the pathname of the parent of this file.

Path Path

Returns the path of this file.

PathSeparator PathSeparator

The system-dependent string used to separate components in search paths (":").

PathSeparatorChar PathSeparatorChar

The system-dependent character used to separate components in search paths (':').

PeerReference PeerReference Inherited from Object
Separator Separator

The system-dependent string used to separate components in filenames ('/').

SeparatorChar SeparatorChar

The system-dependent character used to separate components in filenames ('/').

ThresholdClass ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

TotalSpace TotalSpace

Returns the total size in bytes of the partition containing this path.

UsableSpace UsableSpace

Returns the number of usable free bytes on the partition containing this path.

Methods

CanExecute() CanExecute()

Tests whether or not this process is allowed to execute this file.

CanRead() CanRead()

Indicates whether the current context is allowed to read from this file.

CanWrite() CanWrite()

Indicates whether the current context is allowed to write to this file.

Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
CompareTo(File) CompareTo(File)

Returns the relative sort ordering of the paths for this file and the file another.

CreateNewFile() CreateNewFile()

Creates a new, empty file on the file system according to the path information stored in this file.

CreateTempFile(String, String) CreateTempFile(String, String)

Creates an empty temporary file using the given prefix and suffix as part of the file name.

CreateTempFile(String, String, File) CreateTempFile(String, String, File)

Creates an empty temporary file in the given directory using the given prefix and suffix as part of the file name.

Delete() Delete()

Deletes this file.

DeleteOnExit() DeleteOnExit()

Schedules this file to be automatically deleted when the VM terminates normally.

Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
Exists() Exists()

Returns a boolean indicating whether this file can be found on the underlying file system.

GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
LastModified() LastModified()

Returns the time when this file was last modified, measured in milliseconds since January 1st, 1970, midnight.

Length() Length()

Returns the length of this file in bytes.

List() List()

Returns an array of strings with the file names in the directory represented by this file.

List(IFilenameFilter) List(IFilenameFilter)

Gets a list of the files in the directory represented by this file.

ListAsync() ListAsync()
ListAsync(IFilenameFilter) ListAsync(IFilenameFilter)
ListFiles() ListFiles()

Returns an array of files contained in the directory represented by this file.

ListFiles(IFileFilter) ListFiles(IFileFilter)

Gets a list of the files in the directory represented by this file.

ListFiles(IFilenameFilter) ListFiles(IFilenameFilter)

Gets a list of the files in the directory represented by this file.

ListFilesAsync() ListFilesAsync()
ListFilesAsync(IFileFilter) ListFilesAsync(IFileFilter)
ListFilesAsync(IFilenameFilter) ListFilesAsync(IFilenameFilter)
ListRoots() ListRoots()

Returns the file system roots.

ListRootsAsync() ListRootsAsync()
Mkdir() Mkdir()

Creates the directory named by this file, assuming its parents exist.

Mkdirs() Mkdirs()

Creates the directory named by this file, creating missing parent directories if necessary.

Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
RenameTo(File) RenameTo(File)

Renames this file to newPath.

SetExecutable(Boolean) SetExecutable(Boolean)

Equivalent to setExecutable(executable, true).

SetExecutable(Boolean, Boolean) SetExecutable(Boolean, Boolean)

Manipulates the execute permissions for the abstract path designated by this file.

SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetLastModified(Int64) SetLastModified(Int64)

Sets the time this file was last modified, measured in milliseconds since January 1st, 1970, midnight.

SetReadable(Boolean) SetReadable(Boolean)

Equivalent to setReadable(readable, true).

SetReadable(Boolean, Boolean) SetReadable(Boolean, Boolean)

Manipulates the read permissions for the abstract path designated by this file.

SetReadOnly() SetReadOnly()

Equivalent to setWritable(false, false).

SetWritable(Boolean) SetWritable(Boolean)

Equivalent to setWritable(writable, true).

SetWritable(Boolean, Boolean) SetWritable(Boolean, Boolean)

Manipulates the write permissions for the abstract path designated by this file.

ToArray<T>() ToArray<T>() Inherited from Object
ToPath() ToPath()
ToString() ToString()

Returns a string containing a concise, human-readable description of this object.

(Inherited from Object)
ToURI() ToURI()

Returns a Uniform Resource Identifier for this file.

ToURL() ToURL()

Returns a Uniform Resource Locator for this file.

UnregisterFromRuntime() UnregisterFromRuntime() Inherited from Object
Wait() Wait()

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)

Explicit Interface Implementations

IComparable.CompareTo(Object) IComparable.CompareTo(Object)
IJavaObjectEx.ToLocalJniHandle() IJavaObjectEx.ToLocalJniHandle() Inherited from Object
IJavaPeerable.Disposed() IJavaPeerable.Disposed() Inherited from Object
IJavaPeerable.DisposeUnlessReferenced() IJavaPeerable.DisposeUnlessReferenced() Inherited from Object
IJavaPeerable.Finalized() IJavaPeerable.Finalized() Inherited from Object
IJavaPeerable.SetJniIdentityHashCode(Int32) IJavaPeerable.SetJniIdentityHashCode(Int32) Inherited from Object
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) Inherited from Object
IJavaPeerable.SetPeerReference(JniObjectReference) IJavaPeerable.SetPeerReference(JniObjectReference) Inherited from Object

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)

Applies to