C# Class Westwind.Utilities.FileUtils

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

Méthodes publiques

Méthode 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

Méthode Description
GetLongPathName ( string ShortPath, StringBuilder sb, int buffer ) : uint

Method Details

CopyStream() public static méthode

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
Résultat void

CopyStream() public static méthode

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
Résultat void

DeleteTimedoutFiles() public static méthode

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
Résultat void

GetFileEncoding() public static méthode

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

GetFullPath() public static méthode

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

GetPhysicalPath() public static méthode

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
Résultat string

GetRelativePath() public static méthode

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.
Résultat string

JustPath() public static méthode

Returns the full path of a full physical filename
public static JustPath ( string path ) : string
path string
Résultat string

OpenStreamReaderWithEncoding() public static méthode

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

SafeFilename() public static méthode

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
Résultat string