Class FileUtils

wwUtils class which contains a set of common utility classes for Formatting strings Reflection Helpers Object Serialization Stream Manipulation

public static class FileUtils : object

Class Members



Adds a trailing slash to a path if there isn't one.

public static string AddTrailingSlash(string path)


Returns a safe filename in CamelCase

public static string CamelCaseSafeFilename(string filename)


public static void CopyDirectory(string sourcePath,     string targetPath,     bool deleteFirst,     bool deepCopy)


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)


Deletes files in a folder based on a file spec recursively

public static int DeleteFiles(string path,     string filespec,     bool recursive)


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)


Expands Path Environment Variables like %appdata% in paths.

public static string ExpandPathEnvironmentVariables(string path)


Creates an MD5 checksum of a file

public static string GetChecksumFromFile(string file,     string hashAlgorithm)


Returns a compact path with elipsis from a long path

public static string GetCompactPath(string path,     int length)


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

public static Encoding GetFileEncoding(string srcFile)


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)


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

public static string GetRelativePath(string fullPath,     string basePath)


Normalizes path with slashes and forces a trailing slash on the end of the path.

public static string NormalizeDirectory(string path)


Normalizes a file path to the operating system default slashes.

public static string NormalizePath(string path)


Opens a stream reader with the appropriate text encoding applied.

public static StreamReader OpenStreamReaderWithEncoding(string srcFile)


Returns a safe filename from a string by stripping out illegal characters

public static string SafeFilename(string fileName,     string replacementString,     string spaceReplacement)


Namespace: Westwind.Utilities
Assembly: westwind.utilities.dll

© West Wind Technologies, 2019 • Updated: 06/23/19
Comment or report problem with topic