C# Класс Westwind.Utilities.FileUtils

wwUtils class which contains a set of common utility classes for Formatting strings Reflection Helpers Object Serialization
Показать файл Открыть проект

Открытые методы

Метод Описание
CopyStream ( Stream source, Stream dest, int bufferSize ) : void

Copies the content of the one stream to another. Streams must be open and stay open.

CopyStream ( Stream source, Stream dest, int bufferSize, bool append ) : void

Copies the content of one stream to another by appending to the target stream Streams must be open when passed in.

DeleteTimedoutFiles ( string filespec, int seconds ) : void

Deletes files based on a file spec and a given timeout. This routine is useful for cleaning up temp files in Web applications.

GetFileEncoding ( string srcFile ) : Encoding

Detects the byte order mark of a file and returns an appropriate encoding for the file.

GetFullPath ( string path ) : string

Returns a fully qualified path from a partial or relative path.

GetPhysicalPath ( string filename ) : string

This function returns the actual filename of a file that exists on disk. If you provide a path/file name that is not proper cased as input, this function fixes it up and returns the file using the path and file names as they exist on disk. If the file doesn't exist the original filename is returned.

GetRelativePath ( string fullPath, string basePath ) : string

Returns a relative path string from a full path based on a base path provided.

JustPath ( string path ) : string

Returns the full path of a full physical filename

OpenStreamReaderWithEncoding ( string srcFile ) : StreamReader

Opens a stream reader with the appropriate text encoding applied.

SafeFilename ( string fileName, string replace = "" ) : string

Creates a safe file and directory name that is stripped of all invalid characters.

Приватные методы

Метод Описание
GetLongPathName ( string ShortPath, StringBuilder sb, int buffer ) : uint

Описание методов

CopyStream() публичный статический Метод

Copies the content of the one stream to another. Streams must be open and stay open.
public static CopyStream ( Stream source, Stream dest, int bufferSize ) : void
source Stream
dest Stream
bufferSize int
Результат void

CopyStream() публичный статический Метод

Copies the content of one stream to another by appending to the target stream Streams must be open when passed in.
public static CopyStream ( Stream source, Stream dest, int bufferSize, bool append ) : void
source Stream
dest Stream
bufferSize int
append bool
Результат void

DeleteTimedoutFiles() публичный статический Метод

Deletes files based on a file spec and a given timeout. This routine is useful for cleaning up temp files in Web applications.
public static DeleteTimedoutFiles ( string filespec, int seconds ) : void
filespec string A filespec that includes path and/or wildcards to select files
seconds int The timeout - if files are older than this timeout they are deleted
Результат void

GetFileEncoding() публичный статический Метод

Detects the byte order mark of a file and returns an appropriate encoding for the file.
public static GetFileEncoding ( string srcFile ) : Encoding
srcFile string
Результат System.Text.Encoding

GetFullPath() публичный статический Метод

Returns a fully qualified path from a partial or relative path.
public static GetFullPath ( string path ) : string
path string
Результат string

GetPhysicalPath() публичный статический Метод

This function returns the actual filename of a file that exists on disk. If you provide a path/file name that is not proper cased as input, this function fixes it up and returns the file using the path and file names as they exist on disk. If the file doesn't exist the original filename is returned.
public static GetPhysicalPath ( string filename ) : string
filename string A filename to check
Результат string

GetRelativePath() публичный статический Метод

Returns a relative path string from a full path based on a base path provided.
public static GetRelativePath ( string fullPath, string basePath ) : string
fullPath string The path to convert. Can be either a file or a directory
basePath string The base path on which relative processing is based. Should be a directory.
Результат string

JustPath() публичный статический Метод

Returns the full path of a full physical filename
public static JustPath ( string path ) : string
path string
Результат string

OpenStreamReaderWithEncoding() публичный статический Метод

Opens a stream reader with the appropriate text encoding applied.
public static OpenStreamReaderWithEncoding ( string srcFile ) : StreamReader
srcFile string
Результат System.IO.StreamReader

SafeFilename() публичный статический Метод

Creates a safe file and directory name that is stripped of all invalid characters.
public static SafeFilename ( string fileName, string replace = "" ) : string
fileName string Filename to clean up
replace string Replacement character for invalid characters
Результат string