This class represents a file as defined by the underlying file system.
Parent Class
Parent Interfaces
Type | Name | Signature |
---|---|---|
constructor | File | public File(string) |
method | create | public bool create() |
method | delete | public bool delete() |
method | exists | public bool exists() |
method | getName | public String getName() |
method | getParent | public Directory getParent() |
method | getPath | public String getPath() |
method | getReadStream | public Stream getReadStream() |
method | getWriteStream | public Stream getWriteStream(bool) |
method | isFile | public bool isFile() |
method | move | public bool move(System.IO.Directory) |
method | readAllText | public String readAllText() |
method | rename | public bool rename(string) |
public File(string path)
Create a new file with the specified path.
Parameters
public bool create()
Create a file represented by this object.
Required Policies
System.IO/write
Returns
Throws
public bool delete()
Delete this file.
Required Policies
System.IO/write
Returns
Throws
public bool exists()
Whether this file exist on file system.
Required Policies
System.IO/stat
Returns
public String getName()
Get the name of this file. This is only the simple name (with extension) on the path.
Required Policies
System.IO/stat
Returns
public Directory getParent()
Get the directory this file resides in.
Required Policies
System.IO/stat
Returns
Throws
public String getPath()
Get the absolute path of this file, including the name.
Required Policies
System.IO/stat
Returns
public Stream getReadStream()
Get a stream to read from this file.
Access policy System.IO/read
must be enabled to perform read operation on this stream.
Returns
See Also
public Stream getWriteStream(bool append)
Get a stream to write into this file.
Access policy System.IO/write
must be enabled to perform write operation on this stream.
Parameters
Returns
See Also
public bool isFile()
Always return true.
Returns
public bool move(Directory newDir)
(INHERITED DOC)
Move this item to another directory.
Unlike a few file systems where the move command/API serves dual purpose, Julian splits the semantics between move and rename. Rename operation is only for renaming without moving around the file, while this method may only be used to move an item from one directory to another without changing its name. The obvious implication of this division is that for the move operation, the destination must be a valid directory, and there must be no item in that directory that is already possessing the same name. In any of these cases this method returns false. Moving to the same directory is allowed and implemented trivially by returning true directly.
To move an item and change its name, use extension method relocate().
Required Policies
System.IO/write
Parameters
Returns
public String readAllText()
Read all the contents from this file as text. This is a rather convenient method for quick scripting, but won't scale well if the file is too large and the operation is too frequent. When dealing with reading large files at high frequency, always consider using an asynchronous stream first.
Required Policies
System.IO/read
Returns
public bool rename(string newName)
(INHERITED DOC)
Rename this item while remaining in the same directory.
Unlike a few file systems where the move command/API serves dual purpose, Julian splits the semantics between move and rename. Move operation may only be used to move an item from one directory to another without changing its name, while this method is only for renaming without moving around the file. The obvious implication of this division is that for the rename operation, the new name must not contain file system separator, and there must be no item within the same directory that is already possessing the same name. In any of these cases this method returns false.
To move an item and change its name, use extension method relocate().
Required Policies
System.IO/write
Parameters
Returns