C# 클래스 EnterpriseWebLibrary.IO.IoMethods

A collection of IO-related static methods.
파일 보기 프로젝트 열기: enduracode/enterprise-web-library 1 사용 예제들

공개 메소드들

메소드 설명
CopyFile ( string sourcePath, string destinationPath ) : void

Creates the destination folder if it does not exist. Overwrites the destination file if it already exists.

CopyFolder ( string src, string dest, bool overwriteExistingFiles ) : void

Recursively copies the contents of the specified source directory to the specified destination directory. Creates the destination directory if it doesn't already exist. Does not overwrite anything in the destination folder if it already exists.

DeleteFile ( string path ) : void

Deletes the file at the given path, or does nothing if it does not exist. Supports deletion of partially or fully read-only files.

DeleteFolder ( string path ) : void

Deletes the specified directory and its contents, if the directory exists. Supports deletion of partially or fully read-only directories.

DownloadFile ( string url, string destinationPath, NetworkCredential credentials ) : void

Creates the destination path if it does not exist, and downloads the file to that destination path. Credentials can be null.

ExecuteWithTempFileStream ( Action method ) : void

Executes the specified method with a stream for a temporary file. The file will be deleted after the method executes.

ExecuteWithTempFolder ( Action method ) : void
GetFileNamesInFolder ( string folderPath, string searchPattern = "*" ) : IEnumerable

Gets a list of file names (not including path) in the specified folder, ordered by modified date descending, that match the specified search pattern. Does not include files in subfolders. If the folder does not exist, returns an empty collection.

GetFilePathsInFolder ( string folderPath, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly ) : IEnumerable

Gets a list of file paths in the specified folder, ordered by last modified date descending, that match the specified search pattern. The default search option is to not include files in subfolders. If the folder does not exist, returns an empty collection.

GetFileStreamForWrite ( string filePath ) : FileStream

Returns a file stream for writing a new file or overwriting an existing file. Automatically creates any folders needed in the given path, if necessary. We recommend passing an absolute path. If a relative path is passed, the working folder is used as the root path. Caller is responsible for properly disposing the stream.

GetFolderNamesInFolder ( string folderPath ) : List

Gets a list of folder names in the specified folder.

GetFolderSize ( string path ) : long

Gets the sum size, in bytes, of everything in the folder at the given path (recursive).

GetTextWriterForWrite ( string filePath ) : TextWriter

Returns a text writer for writing a new file or overwriting an existing file. Automatically creates any folders needed in the given path, if necessary. We recommend passing an absolute path. If a relative path is passed, the working folder is used as the root path. Caller is responsible for properly disposing the stream.

MoveFile ( string sourcePath, string destinationPath ) : void

Overwrites the destination path.

RecursivelyRemoveReadOnlyAttributeFromItem ( string path ) : void

Recursively removes the read-only attribute from the specified file or folder.

비공개 메소드들

메소드 설명
CopyStream ( Stream sourceStream, Stream destinationStream, int bufferSize = 65536 ) : void
handleFailedDeletion ( string path, int &numberOfFailures, Exception exception ) : void

메소드 상세

CopyFile() 공개 정적인 메소드

Creates the destination folder if it does not exist. Overwrites the destination file if it already exists.
public static CopyFile ( string sourcePath, string destinationPath ) : void
sourcePath string
destinationPath string
리턴 void

CopyFolder() 공개 정적인 메소드

Recursively copies the contents of the specified source directory to the specified destination directory. Creates the destination directory if it doesn't already exist. Does not overwrite anything in the destination folder if it already exists.
public static CopyFolder ( string src, string dest, bool overwriteExistingFiles ) : void
src string
dest string
overwriteExistingFiles bool
리턴 void

DeleteFile() 공개 정적인 메소드

Deletes the file at the given path, or does nothing if it does not exist. Supports deletion of partially or fully read-only files.
public static DeleteFile ( string path ) : void
path string
리턴 void

DeleteFolder() 공개 정적인 메소드

Deletes the specified directory and its contents, if the directory exists. Supports deletion of partially or fully read-only directories.
public static DeleteFolder ( string path ) : void
path string
리턴 void

DownloadFile() 공개 정적인 메소드

Creates the destination path if it does not exist, and downloads the file to that destination path. Credentials can be null.
public static DownloadFile ( string url, string destinationPath, NetworkCredential credentials ) : void
url string
destinationPath string
credentials System.Net.NetworkCredential
리턴 void

ExecuteWithTempFileStream() 공개 정적인 메소드

Executes the specified method with a stream for a temporary file. The file will be deleted after the method executes.
public static ExecuteWithTempFileStream ( Action method ) : void
method Action
리턴 void

ExecuteWithTempFolder() 공개 정적인 메소드

public static ExecuteWithTempFolder ( Action method ) : void
method Action
리턴 void

GetFileNamesInFolder() 공개 정적인 메소드

Gets a list of file names (not including path) in the specified folder, ordered by modified date descending, that match the specified search pattern. Does not include files in subfolders. If the folder does not exist, returns an empty collection.
public static GetFileNamesInFolder ( string folderPath, string searchPattern = "*" ) : IEnumerable
folderPath string
searchPattern string
리턴 IEnumerable

GetFilePathsInFolder() 공개 정적인 메소드

Gets a list of file paths in the specified folder, ordered by last modified date descending, that match the specified search pattern. The default search option is to not include files in subfolders. If the folder does not exist, returns an empty collection.
public static GetFilePathsInFolder ( string folderPath, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly ) : IEnumerable
folderPath string
searchPattern string
searchOption SearchOption
리턴 IEnumerable

GetFileStreamForWrite() 공개 정적인 메소드

Returns a file stream for writing a new file or overwriting an existing file. Automatically creates any folders needed in the given path, if necessary. We recommend passing an absolute path. If a relative path is passed, the working folder is used as the root path. Caller is responsible for properly disposing the stream.
public static GetFileStreamForWrite ( string filePath ) : FileStream
filePath string
리턴 System.IO.FileStream

GetFolderNamesInFolder() 공개 정적인 메소드

Gets a list of folder names in the specified folder.
public static GetFolderNamesInFolder ( string folderPath ) : List
folderPath string
리턴 List

GetFolderSize() 공개 정적인 메소드

Gets the sum size, in bytes, of everything in the folder at the given path (recursive).
public static GetFolderSize ( string path ) : long
path string
리턴 long

GetTextWriterForWrite() 공개 정적인 메소드

Returns a text writer for writing a new file or overwriting an existing file. Automatically creates any folders needed in the given path, if necessary. We recommend passing an absolute path. If a relative path is passed, the working folder is used as the root path. Caller is responsible for properly disposing the stream.
public static GetTextWriterForWrite ( string filePath ) : TextWriter
filePath string
리턴 System.IO.TextWriter

MoveFile() 공개 정적인 메소드

Overwrites the destination path.
public static MoveFile ( string sourcePath, string destinationPath ) : void
sourcePath string
destinationPath string
리턴 void

RecursivelyRemoveReadOnlyAttributeFromItem() 공개 정적인 메소드

Recursively removes the read-only attribute from the specified file or folder.
public static RecursivelyRemoveReadOnlyAttributeFromItem ( string path ) : void
path string
리턴 void