Difference between revisions of "API:FileInfo"

From Kerbal Space Program Wiki
Jump to: navigation, search
 
Line 5: Line 5:
 
|summary=A surrogate for System.IO.FileInfo.
 
|summary=A surrogate for System.IO.FileInfo.
 
}}
 
}}
 +
{{PropertiesStart}}
 +
{{Property
 +
|type=long
 +
|name=Length
 +
|desc=Gets the size, in bytes, of the current file.
 +
|hasget=1
 +
|hasset=
 +
}}
 +
{{Property
 +
|type=string
 +
|name=DirectoryName
 +
|desc=Gets a string representing the directory's full path.
 +
|hasget=1
 +
|hasset=
 +
}}
 +
{{Property
 +
|type=string
 +
|name=Name
 +
|desc=Gets the name of the file.
 +
|hasget=1
 +
|hasset=
 +
}}
 +
{{Property
 +
|type=bool
 +
|name=Exists
 +
|desc=Gets a value indicating whether a file exists.
 +
|hasget=1
 +
|hasset=
 +
}}
 +
{{Property
 +
|type=bool
 +
|name=IsReadOnly
 +
|desc=Gets or sets a value that determines if the current file is read only.
 +
|hasget=1
 +
|hasset=1
 +
}}
 +
{{PropertiesEnd}}
 
{{MethodsStart}}
 
{{MethodsStart}}
 
{{StaticMethod
 
{{StaticMethod

Latest revision as of 23:43, 12 October 2012

KSP.IO Namespace
BinaryReader · BinaryWriter · File · FileInfo · FileStream · IOException · IOTools · IOUtils · MemoryStream · PluginConfigNode · PluginConfiguration · TextReader · TextWriter

FileInfo Class

A surrogate for System.IO.FileInfo.

Properties

The following are public properties available in FileInfo.

Signature Description
long Length { get; } Gets the size, in bytes, of the current file.
string DirectoryName { get; } Gets a string representing the directory's full path.
string Name { get; } Gets the name of the file.
bool Exists { get; } Gets a value indicating whether a file exists.
bool IsReadOnly { get; set; } Gets or sets a value that determines if the current file is read only.

Methods

The following are methods included in FileInfo.

Signature Description
static FileInfo CreateForType<T>(string filename, Vessel flight = null) Create a text reader stream.
FileInfo Replace(string destinationFileName, string destinationBackupFileName) Replaces the contents of a specified file with the file described by the current System.IO.FileInfo object, deleting the original file, and creating a backup of the replaced file.
void Encrypt() Encrypts a file so that only the account used to encrypt the file can decrypt it.
void Delete() Permanently deletes a file.
FileStream Create() Creates a file.
FileInfo CopyTo(string destFileName, bool overwrite) Copies an existing file to a new file, allowing the overwriting of an existing file.
FileStream Open(FileMode mode, FileAccess access) Opens a file in the specified mode with read, write, or read/write access.
FileStream OpenWrite() Creates a write-only System.IO.FileStream.
void MoveTo(string destFileName) Moves a specified file to a new location, providing the option to specify a new file name.
TextWriter AppendText() Creates a System.IO.StreamWriter that appends text to the file represented by this instance of the System.IO.FileInfo.
FileStream Open(FileMode mode) Opens a file in the specified mode.
FileStream OpenRead() Creates a read-only System.IO.FileStream.
TextWriter CreateText() Creates a KSP.IO.TextWriter that writes a new text file.
string ToString() Returns the path as a string.
TextReader OpenText() Creates a System.IO.StreamReader with UTF8 encoding that reads from an existing text file.
FileStream Open(FileMode mode, FileAccess access, FileShare share) Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.
void Decrypt() Decrypts a file that was encrypted by the current account using the System.IO.FileInfo.Encrypt() method.
FileInfo CopyTo(string destFileName) Copies an existing file to a new file, disallowing the overwriting of an existing file.
FileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors) Replaces the contents of a specified file with the file described by the current System.IO.FileInfo object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.