C# 클래스 System.IO.Abstractions.FileBase

파일 보기 프로젝트 열기: tathamoddie/System.IO.Abstractions 1 사용 예제들

공개 메소드들

메소드 설명
AppendAllLines ( string path, IEnumerable contents ) : void
AppendAllLines ( string path, IEnumerable contents, Encoding encoding ) : void
AppendAllText ( string path, string contents ) : void
AppendAllText ( string path, string contents, Encoding encoding ) : void
AppendText ( string path ) : StreamWriter
Copy ( string sourceFileName, string destFileName ) : void
Copy ( string sourceFileName, string destFileName, bool overwrite ) : void
Create ( string path ) : Stream
Create ( string path, int bufferSize ) : Stream
Create ( string path, int bufferSize, FileOptions options ) : Stream
Create ( string path, int bufferSize, FileOptions options, FileSecurity fileSecurity ) : Stream
CreateText ( string path ) : StreamWriter
Decrypt ( string path ) : void
Delete ( string path ) : void
Encrypt ( string path ) : void
Exists ( string path ) : bool

Determines whether the specified file exists.

The Exists method should not be used for path validation, this method merely checks if the file specified in path exists. Passing an invalid path to Exists returns .

Be aware that another process can potentially do something with the file in between the time you call the Exists method and perform another operation on the file, such as Delete.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If path describes a directory, this method returns . Trailing spaces are removed from the path parameter before determining if the file exists.

The Exists method returns if any error occurs while trying to determine if the specified file exists. This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters a failing or missing disk, or if the caller does not have permission to read the file.

GetAccessControl ( string path ) : FileSecurity
GetAccessControl ( string path, AccessControlSections includeSections ) : FileSecurity
GetAttributes ( string path ) : FileAttributes

Gets the FileAttributes of the file on the path.

GetCreationTime ( string path ) : DateTime

Returns the creation date and time of the specified file or directory.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

GetCreationTimeUtc ( string path ) : DateTime

Returns the creation date and time, in coordinated universal time (UTC), of the specified file or directory.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

GetLastAccessTime ( string path ) : DateTime

Returns the date and time the specified file or directory was last accessed.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

GetLastAccessTimeUtc ( string path ) : DateTime

Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

GetLastWriteTime ( string path ) : DateTime

Returns the date and time the specified file or directory was last written to.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

GetLastWriteTimeUtc ( string path ) : DateTime

Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

Move ( string sourceFileName, string destFileName ) : void
Open ( string path, FileMode mode ) : Stream
Open ( string path, FileMode mode, FileAccess access ) : Stream
Open ( string path, FileMode mode, FileAccess access, FileShare share ) : Stream
OpenRead ( string path ) : Stream
OpenText ( string path ) : StreamReader
OpenWrite ( string path ) : Stream
ReadAllBytes ( string path ) : byte[]
ReadAllLines ( string path ) : string[]
ReadAllLines ( string path, Encoding encoding ) : string[]
ReadAllText ( string path ) : string
ReadAllText ( string path, Encoding encoding ) : string
ReadLines ( string path ) : IEnumerable
ReadLines ( string path, Encoding encoding ) : IEnumerable
Replace ( string sourceFileName, string destinationFileName, string destinationBackupFileName ) : void
Replace ( string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors ) : void
SetAccessControl ( string path, FileSecurity fileSecurity ) : void
SetAttributes ( string path, FileAttributes fileAttributes ) : void
SetCreationTime ( string path, DateTime creationTime ) : void
SetCreationTimeUtc ( string path, DateTime creationTimeUtc ) : void
SetLastAccessTime ( string path, DateTime lastAccessTime ) : void
SetLastAccessTimeUtc ( string path, DateTime lastAccessTimeUtc ) : void
SetLastWriteTime ( string path, DateTime lastWriteTime ) : void
SetLastWriteTimeUtc ( string path, DateTime lastWriteTimeUtc ) : void
WriteAllBytes ( string path, byte bytes ) : void

Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten.

Given a byte array and a file path, this method opens the specified file, writes the contents of the byte array to the file, and then closes the file.

WriteAllLines ( string path, IEnumerable contents ) : void

Creates a new file, writes a collection of strings to the file, and then closes the file.

If the target file already exists, it is overwritten.

You can use this method to create the contents for a collection class that takes an IEnumerable{T} in its constructor, such as a List{T}, HashSet{T}, or a SortedSet{T} class.

WriteAllLines ( string path, IEnumerable contents, Encoding encoding ) : void

Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file.

If the target file already exists, it is overwritten.

You can use this method to create a file that contains the following: The results of a LINQ to Objects query on the lines of a file, as obtained by using the ReadLines method. The contents of a collection that implements an IEnumerable{T} of strings.

WriteAllLines ( string path, string contents ) : void

Creates a new file, writes the specified string array to the file by using the specified encoding, and then closes the file.

If the target file already exists, it is overwritten.

The default behavior of the WriteAllLines method is to write out data using UTF-8 encoding without a byte order mark (BOM). If it is necessary to include a UTF-8 identifier, such as a byte order mark, at the beginning of a file, use the WriteAllLines(string, string[], Encoding) method overload with UTF8Encoding encoding.

Given a string array and a file path, this method opens the specified file, writes the string array to the file using the specified encoding, and then closes the file.

WriteAllLines ( string path, string contents, Encoding encoding ) : void

Creates a new file, writes the specified string array to the file by using the specified encoding, and then closes the file.

If the target file already exists, it is overwritten.

Given a string array and a file path, this method opens the specified file, writes the string array to the file using the specified encoding, and then closes the file.

WriteAllText ( string path, string contents ) : void

Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten.

This method uses UTF-8 encoding without a Byte-Order Mark (BOM), so using the M:Encoding.GetPreamble method will return an empty byte array. If it is necessary to include a UTF-8 identifier, such as a byte order mark, at the beginning of a file, use the WriteAllText(string,string, Encoding) method overload with UTF8Encoding encoding.

Given a string and a file path, this method opens the specified file, writes the string to the file, and then closes the file.

WriteAllText ( string path, string contents, Encoding encoding ) : void

Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten.

Given a string and a file path, this method opens the specified file, writes the string to the file using the specified encoding, and then closes the file. The file handle is guaranteed to be closed by this method, even if exceptions are raised.

메소드 상세

AppendAllLines() 공개 추상적인 메소드

public abstract AppendAllLines ( string path, IEnumerable contents ) : void
path string
contents IEnumerable
리턴 void

AppendAllLines() 공개 추상적인 메소드

public abstract AppendAllLines ( string path, IEnumerable contents, Encoding encoding ) : void
path string
contents IEnumerable
encoding System.Text.Encoding
리턴 void

AppendAllText() 공개 추상적인 메소드

public abstract AppendAllText ( string path, string contents ) : void
path string
contents string
리턴 void

AppendAllText() 공개 추상적인 메소드

public abstract AppendAllText ( string path, string contents, Encoding encoding ) : void
path string
contents string
encoding System.Text.Encoding
리턴 void

AppendText() 공개 추상적인 메소드

public abstract AppendText ( string path ) : StreamWriter
path string
리턴 StreamWriter

Copy() 공개 추상적인 메소드

public abstract Copy ( string sourceFileName, string destFileName ) : void
sourceFileName string
destFileName string
리턴 void

Copy() 공개 추상적인 메소드

public abstract Copy ( string sourceFileName, string destFileName, bool overwrite ) : void
sourceFileName string
destFileName string
overwrite bool
리턴 void

Create() 공개 추상적인 메소드

public abstract Create ( string path ) : Stream
path string
리턴 Stream

Create() 공개 추상적인 메소드

public abstract Create ( string path, int bufferSize ) : Stream
path string
bufferSize int
리턴 Stream

Create() 공개 추상적인 메소드

public abstract Create ( string path, int bufferSize, FileOptions options ) : Stream
path string
bufferSize int
options FileOptions
리턴 Stream

Create() 공개 추상적인 메소드

public abstract Create ( string path, int bufferSize, FileOptions options, FileSecurity fileSecurity ) : Stream
path string
bufferSize int
options FileOptions
fileSecurity System.Security.AccessControl.FileSecurity
리턴 Stream

CreateText() 공개 추상적인 메소드

public abstract CreateText ( string path ) : StreamWriter
path string
리턴 StreamWriter

Decrypt() 공개 추상적인 메소드

public abstract Decrypt ( string path ) : void
path string
리턴 void

Delete() 공개 추상적인 메소드

public abstract Delete ( string path ) : void
path string
리턴 void

Encrypt() 공개 추상적인 메소드

public abstract Encrypt ( string path ) : void
path string
리턴 void

Exists() 공개 추상적인 메소드

Determines whether the specified file exists.

The Exists method should not be used for path validation, this method merely checks if the file specified in path exists. Passing an invalid path to Exists returns .

Be aware that another process can potentially do something with the file in between the time you call the Exists method and perform another operation on the file, such as Delete.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If path describes a directory, this method returns . Trailing spaces are removed from the path parameter before determining if the file exists.

The Exists method returns if any error occurs while trying to determine if the specified file exists. This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters a failing or missing disk, or if the caller does not have permission to read the file.

public abstract Exists ( string path ) : bool
path string The file to check.
리턴 bool

GetAccessControl() 공개 추상적인 메소드

public abstract GetAccessControl ( string path ) : FileSecurity
path string
리턴 System.Security.AccessControl.FileSecurity

GetAccessControl() 공개 추상적인 메소드

public abstract GetAccessControl ( string path, AccessControlSections includeSections ) : FileSecurity
path string
includeSections AccessControlSections
리턴 System.Security.AccessControl.FileSecurity

GetAttributes() 공개 추상적인 메소드

Gets the FileAttributes of the file on the path.
is empty, contains only white spaces, or contains invalid characters. The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. is in an invalid format. represents a file and is invalid, such as being on an unmapped drive, or the file cannot be found. represents a directory and is invalid, such as being on an unmapped drive, or the directory cannot be found. This file is being used by another process. The caller does not have the required permission.
public abstract GetAttributes ( string path ) : FileAttributes
path string The path to the file.
리턴 FileAttributes

GetCreationTime() 공개 추상적인 메소드

Returns the creation date and time of the specified file or directory.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

The caller does not have the required permission. is empty, contains only white spaces, or contains invalid characters. is . The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. is in an invalid format.
public abstract GetCreationTime ( string path ) : DateTime
path string The file or directory for which to obtain creation date and time information.
리턴 DateTime

GetCreationTimeUtc() 공개 추상적인 메소드

Returns the creation date and time, in coordinated universal time (UTC), of the specified file or directory.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

The caller does not have the required permission. is empty, contains only white spaces, or contains invalid characters. is . The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. is in an invalid format.
public abstract GetCreationTimeUtc ( string path ) : DateTime
path string The file or directory for which to obtain creation date and time information.
리턴 DateTime

GetLastAccessTime() 공개 추상적인 메소드

Returns the date and time the specified file or directory was last accessed.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

The caller does not have the required permission. is empty, contains only white spaces, or contains invalid characters. is . The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. is in an invalid format.
public abstract GetLastAccessTime ( string path ) : DateTime
path string The file or directory for which to obtain access date and time information.
리턴 DateTime

GetLastAccessTimeUtc() 공개 추상적인 메소드

Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

The caller does not have the required permission. is empty, contains only white spaces, or contains invalid characters. is . The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. is in an invalid format.
public abstract GetLastAccessTimeUtc ( string path ) : DateTime
path string The file or directory for which to obtain creation date and time information.
리턴 DateTime

GetLastWriteTime() 공개 추상적인 메소드

Returns the date and time the specified file or directory was last written to.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

The caller does not have the required permission. is empty, contains only white spaces, or contains invalid characters. is . The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. is in an invalid format.
public abstract GetLastWriteTime ( string path ) : DateTime
path string The file or directory for which to obtain creation date and time information.
리턴 DateTime

GetLastWriteTimeUtc() 공개 추상적인 메소드

Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see DirectoryBase.GetCurrentDirectory.

NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time, which is known as "file tunneling." As a result, it may be necessary to explicitly set the creation time of a file if you are overwriting or replacing an existing file.

The caller does not have the required permission. is empty, contains only white spaces, or contains invalid characters. is . The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. is in an invalid format.
public abstract GetLastWriteTimeUtc ( string path ) : DateTime
path string The file or directory for which to obtain creation date and time information.
리턴 DateTime

Move() 공개 추상적인 메소드

public abstract Move ( string sourceFileName, string destFileName ) : void
sourceFileName string
destFileName string
리턴 void

Open() 공개 추상적인 메소드

public abstract Open ( string path, FileMode mode ) : Stream
path string
mode FileMode
리턴 Stream

Open() 공개 추상적인 메소드

public abstract Open ( string path, FileMode mode, FileAccess access ) : Stream
path string
mode FileMode
access FileAccess
리턴 Stream

Open() 공개 추상적인 메소드

public abstract Open ( string path, FileMode mode, FileAccess access, FileShare share ) : Stream
path string
mode FileMode
access FileAccess
share FileShare
리턴 Stream

OpenRead() 공개 추상적인 메소드

public abstract OpenRead ( string path ) : Stream
path string
리턴 Stream

OpenText() 공개 추상적인 메소드

public abstract OpenText ( string path ) : StreamReader
path string
리턴 StreamReader

OpenWrite() 공개 추상적인 메소드

public abstract OpenWrite ( string path ) : Stream
path string
리턴 Stream

ReadAllBytes() 공개 추상적인 메소드

public abstract ReadAllBytes ( string path ) : byte[]
path string
리턴 byte[]

ReadAllLines() 공개 추상적인 메소드

public abstract ReadAllLines ( string path ) : string[]
path string
리턴 string[]

ReadAllLines() 공개 추상적인 메소드

public abstract ReadAllLines ( string path, Encoding encoding ) : string[]
path string
encoding System.Text.Encoding
리턴 string[]

ReadAllText() 공개 추상적인 메소드

public abstract ReadAllText ( string path ) : string
path string
리턴 string

ReadAllText() 공개 추상적인 메소드

public abstract ReadAllText ( string path, Encoding encoding ) : string
path string
encoding System.Text.Encoding
리턴 string

ReadLines() 공개 추상적인 메소드

public abstract ReadLines ( string path ) : IEnumerable
path string
리턴 IEnumerable

ReadLines() 공개 추상적인 메소드

public abstract ReadLines ( string path, Encoding encoding ) : IEnumerable
path string
encoding System.Text.Encoding
리턴 IEnumerable

Replace() 공개 추상적인 메소드

public abstract Replace ( string sourceFileName, string destinationFileName, string destinationBackupFileName ) : void
sourceFileName string
destinationFileName string
destinationBackupFileName string
리턴 void

Replace() 공개 추상적인 메소드

public abstract Replace ( string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors ) : void
sourceFileName string
destinationFileName string
destinationBackupFileName string
ignoreMetadataErrors bool
리턴 void

SetAccessControl() 공개 추상적인 메소드

public abstract SetAccessControl ( string path, FileSecurity fileSecurity ) : void
path string
fileSecurity System.Security.AccessControl.FileSecurity
리턴 void

SetAttributes() 공개 추상적인 메소드

public abstract SetAttributes ( string path, FileAttributes fileAttributes ) : void
path string
fileAttributes FileAttributes
리턴 void

SetCreationTime() 공개 추상적인 메소드

public abstract SetCreationTime ( string path, DateTime creationTime ) : void
path string
creationTime DateTime
리턴 void

SetCreationTimeUtc() 공개 추상적인 메소드

public abstract SetCreationTimeUtc ( string path, DateTime creationTimeUtc ) : void
path string
creationTimeUtc DateTime
리턴 void

SetLastAccessTime() 공개 추상적인 메소드

public abstract SetLastAccessTime ( string path, DateTime lastAccessTime ) : void
path string
lastAccessTime DateTime
리턴 void

SetLastAccessTimeUtc() 공개 추상적인 메소드

public abstract SetLastAccessTimeUtc ( string path, DateTime lastAccessTimeUtc ) : void
path string
lastAccessTimeUtc DateTime
리턴 void

SetLastWriteTime() 공개 추상적인 메소드

public abstract SetLastWriteTime ( string path, DateTime lastWriteTime ) : void
path string
lastWriteTime DateTime
리턴 void

SetLastWriteTimeUtc() 공개 추상적인 메소드

public abstract SetLastWriteTimeUtc ( string path, DateTime lastWriteTimeUtc ) : void
path string
lastWriteTimeUtc DateTime
리턴 void

WriteAllBytes() 공개 추상적인 메소드

Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten.
Given a byte array and a file path, this method opens the specified file, writes the contents of the byte array to the file, and then closes the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . is or contents is empty. /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). An I/O error occurred while opening the file. /// path specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// path specified a directory. /// -or- /// The caller does not have the required permission. /// The file specified in was not found. is in an invalid format. The caller does not have the required permission.
public abstract WriteAllBytes ( string path, byte bytes ) : void
path string The file to write to.
bytes byte The bytes to write to the file.
리턴 void

WriteAllLines() 공개 추상적인 메소드

Creates a new file, writes a collection of strings to the file, and then closes the file.

If the target file already exists, it is overwritten.

You can use this method to create the contents for a collection class that takes an IEnumerable{T} in its constructor, such as a List{T}, HashSet{T}, or a SortedSet{T} class.

is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . Either or is . The specified path is invalid (for example, it is on an unmapped drive). The file specified in was not found. An I/O error occurred while opening the file. /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// is in an invalid format. The caller does not have the required permission. /// specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// specified a directory. /// -or- /// The caller does not have the required permission. ///
public abstract WriteAllLines ( string path, IEnumerable contents ) : void
path string The file to write to.
contents IEnumerable The lines to write to the file.
리턴 void

WriteAllLines() 공개 추상적인 메소드

Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file.

If the target file already exists, it is overwritten.

You can use this method to create a file that contains the following: The results of a LINQ to Objects query on the lines of a file, as obtained by using the ReadLines method. The contents of a collection that implements an IEnumerable{T} of strings.

is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . Either , , or is . The specified path is invalid (for example, it is on an unmapped drive). The file specified in was not found. An I/O error occurred while opening the file. /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// is in an invalid format. The caller does not have the required permission. /// specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// specified a directory. /// -or- /// The caller does not have the required permission. ///
public abstract WriteAllLines ( string path, IEnumerable contents, Encoding encoding ) : void
path string The file to write to.
contents IEnumerable The lines to write to the file.
encoding System.Text.Encoding The character encoding to use.
리턴 void

WriteAllLines() 공개 추상적인 메소드

Creates a new file, writes the specified string array to the file by using the specified encoding, and then closes the file.

If the target file already exists, it is overwritten.

The default behavior of the WriteAllLines method is to write out data using UTF-8 encoding without a byte order mark (BOM). If it is necessary to include a UTF-8 identifier, such as a byte order mark, at the beginning of a file, use the WriteAllLines(string, string[], Encoding) method overload with UTF8Encoding encoding.

Given a string array and a file path, this method opens the specified file, writes the string array to the file using the specified encoding, and then closes the file.

is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . Either or is . /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). An I/O error occurred while opening the file. /// specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// specified a directory. /// -or- /// The caller does not have the required permission. /// The file specified in was not found. is in an invalid format. The caller does not have the required permission.
public abstract WriteAllLines ( string path, string contents ) : void
path string The file to write to.
contents string The string array to write to the file.
리턴 void

WriteAllLines() 공개 추상적인 메소드

Creates a new file, writes the specified string array to the file by using the specified encoding, and then closes the file.

If the target file already exists, it is overwritten.

Given a string array and a file path, this method opens the specified file, writes the string array to the file using the specified encoding, and then closes the file.

is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . Either or is . /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). An I/O error occurred while opening the file. /// specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// specified a directory. /// -or- /// The caller does not have the required permission. /// The file specified in was not found. is in an invalid format. The caller does not have the required permission.
public abstract WriteAllLines ( string path, string contents, Encoding encoding ) : void
path string The file to write to.
contents string The string array to write to the file.
encoding System.Text.Encoding An object that represents the character encoding applied to the string array.
리턴 void

WriteAllText() 공개 추상적인 메소드

Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten.
This method uses UTF-8 encoding without a Byte-Order Mark (BOM), so using the M:Encoding.GetPreamble method will return an empty byte array. If it is necessary to include a UTF-8 identifier, such as a byte order mark, at the beginning of a file, use the WriteAllText(string,string, Encoding) method overload with UTF8Encoding encoding.

Given a string and a file path, this method opens the specified file, writes the string to the file, and then closes the file.

is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . is or contents is empty. /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). An I/O error occurred while opening the file. /// path specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// path specified a directory. /// -or- /// The caller does not have the required permission. /// The file specified in was not found. is in an invalid format. The caller does not have the required permission.
public abstract WriteAllText ( string path, string contents ) : void
path string The file to write to.
contents string The string to write to the file.
리턴 void

WriteAllText() 공개 추상적인 메소드

Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten.
Given a string and a file path, this method opens the specified file, writes the string to the file using the specified encoding, and then closes the file. The file handle is guaranteed to be closed by this method, even if exceptions are raised.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . is or contents is empty. /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). An I/O error occurred while opening the file. /// path specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// path specified a directory. /// -or- /// The caller does not have the required permission. /// The file specified in was not found. is in an invalid format. The caller does not have the required permission.
public abstract WriteAllText ( string path, string contents, Encoding encoding ) : void
path string The file to write to.
contents string The string to write to the file.
encoding System.Text.Encoding The encoding to apply to the string.
리턴 void