C# Class Westwind.Utilities.FileUtils

wwUtils class which contains a set of common utility classes for Formatting strings Reflection Helpers Object Serialization
Mostrar archivo Open project: RickStrahl/WestwindToolkit

Public Methods

Method Description
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.

Private Methods

Method Description
GetLongPathName ( string ShortPath, StringBuilder sb, int buffer ) : uint

Method Details

CopyStream() public static method

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
return void

CopyStream() public static method

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
return void

DeleteTimedoutFiles() public static method

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
return void

GetFileEncoding() public static method

Detects the byte order mark of a file and returns an appropriate encoding for the file.
public static GetFileEncoding ( string srcFile ) : Encoding
srcFile string
return System.Text.Encoding

GetFullPath() public static method

Returns a fully qualified path from a partial or relative path.
public static GetFullPath ( string path ) : string
path string
return string

GetPhysicalPath() public static method

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
return string

GetRelativePath() public static method

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.
return string

JustPath() public static method

Returns the full path of a full physical filename
public static JustPath ( string path ) : string
path string
return string

OpenStreamReaderWithEncoding() public static method

Opens a stream reader with the appropriate text encoding applied.
public static OpenStreamReaderWithEncoding ( string srcFile ) : StreamReader
srcFile string
return System.IO.StreamReader

SafeFilename() public static method

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
return string