wwUtils class which contains a set of common utility classes for Formatting strings Reflection Helpers Object Serialization Stream Manipulation
Westwind.Utilities.FileUtils
public static class FileUtils : object
Class Members
Member | Description | |
---|---|---|
AddTrailingSlash |
Adds a trailing slash to a path if there isn't one. public static string AddTrailingSlash(string path) |
|
CamelCaseSafeFilename |
Returns a safe filename in CamelCase public static string CamelCaseSafeFilename(string filename) |
|
CopyDirectory |
public static void CopyDirectory(string sourcePath, string targetPath, bool deleteFirst, bool deepCopy) |
|
CopyStream |
Copies the content of the one stream to another. Streams must be open and stay open. public static void CopyStream(Stream source, Stream dest, int bufferSize) public static void CopyStream(Stream source, Stream dest, int bufferSize, bool append) |
|
DeleteFiles |
Deletes files in a folder based on a file spec recursively public static int DeleteFiles(string path, string filespec, bool recursive) |
|
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 void DeleteTimedoutFiles(string filespec, int seconds) |
|
ExpandPathEnvironmentVariables |
Expands Path Environment Variables like %appdata% in paths. public static string ExpandPathEnvironmentVariables(string path) |
|
GetChecksumFromFile |
Creates an MD5 checksum of a file public static string GetChecksumFromFile(string file, string hashAlgorithm) |
|
GetCompactPath |
Returns a compact path with elipsis from a long path public static string GetCompactPath(string path, int length) |
|
GetFileEncoding |
Detects the byte order mark of a file and returns an appropriate encoding for the file. public static Encoding GetFileEncoding(string srcFile) |
|
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 string GetPhysicalPath(string filename) |
|
GetRelativePath |
Returns a relative path string from a full path based on a base path provided. public static string GetRelativePath(string fullPath, string basePath) |
|
NormalizeDirectory |
Normalizes path with slashes and forces a trailing slash on the end of the path. public static string NormalizeDirectory(string path) |
|
NormalizePath |
Normalizes a file path to the operating system default slashes. public static string NormalizePath(string path) |
|
OpenStreamReaderWithEncoding |
Opens a stream reader with the appropriate text encoding applied. public static StreamReader OpenStreamReaderWithEncoding(string srcFile) |
|
SafeFilename |
Returns a safe filename from a string by stripping out illegal characters public static string SafeFilename(string fileName, string replacementString, string spaceReplacement) |
Requirements
Namespace: Westwind.UtilitiesAssembly: westwind.utilities.dll
© West Wind Technologies, 1996-2020 • Updated: 07/15/20
Comment or report problem with topic