CSharpUtilities::FileUtilities Class Reference


Detailed Description

Class that contains useful file-related operations.

List of all members.

Static Public Member Functions

static void  CopyAndMakeWriteable (String sourcePath, String destinationPath)
  Copies source file to destination and makes it writeable.
static void  SafeWrite (String destinationPath, WriteMethod write)
  Wraps a delegate write method to ensure that any exception thrown during the write process does not corrupt the original file.
static void  SafeWriteXml (String destinationPath, XmlWriteMethod write)
  Wraps a delegate write method to ensure that any exception thrown during the write process does not corrupt the original file.
static void  SafeWriteXml (String destinationPath, XmlWriteMethod write, XmlWriterSettings settings)
  Wraps a delegate write method to ensure that any exception thrown during the write process does not corrupt the original file.
static void  SafeWriteText (String destinationPath, TextWriteMethod write)
  Wraps a delegate write method to ensure that any exception thrown during the write process does not corrupt the original file.

Properties

static XmlWriterSettings  XmlWriterSettings [get, set]
  Recommended file settings for xml files written by the application.

Member Function Documentation

static void CSharpUtilities::FileUtilities::CopyAndMakeWriteable ( String  sourcePath,
String  destinationPath 
) [inline, static]

Copies source file to destination and makes it writeable.

Parameters:
sourcePath The file to copy.
destinationPath The place to copy it to.
static void CSharpUtilities::FileUtilities::SafeWrite ( String  destinationPath,
WriteMethod  write 
) [inline, static]

Wraps a delegate write method to ensure that any exception thrown during the write process does not corrupt the original file.

SafeWrite works by:

  1. Opening a FileStream on a temporary file with write permissions
  2. Passing the stream to the delegate to carry out the actual writing
  3. Moving the successfully written file to the actual destination path

The WriteMethod must close any enclosing writer it creates, and the stream through that close, in order to guarantee that all its output is flushed to the file.

Parameters:
destinationPath Output location for the written file.
write Delegate to perform the specific writing.
static void CSharpUtilities::FileUtilities::SafeWriteXml ( String  destinationPath,
XmlWriteMethod  write 
) [inline, static]

Wraps a delegate write method to ensure that any exception thrown during the write process does not corrupt the original file.

SafeWriteXml is a convenience method around SafeWrite for writing XML documents. It provides an XmlWriter to the delegate and ensures that the writer is flushed and closed after the delegate returns control. SafeWrite

This version uses the default FileUtilities.XmlWriterSettings as the XmlWriter's settings.

Parameters:
destinationPath Output location for the written file.
write Delegate to perform the specific writing.
static void CSharpUtilities::FileUtilities::SafeWriteXml ( String  destinationPath,
XmlWriteMethod  write,
XmlWriterSettings  settings 
) [inline, static]

Wraps a delegate write method to ensure that any exception thrown during the write process does not corrupt the original file.

SafeWriteXml is a convenience method around SafeWrite for writing XML documents. It provides an XmlWriter to the delegate and ensures that the writer is flushed and closed after the delegate returns control. SafeWrite

Parameters:
destinationPath Output location for the written file.
write Delegate to perform the specific writing.
settings XmlWriterSettings to use in the XmlWriter
static void CSharpUtilities::FileUtilities::SafeWriteText ( String  destinationPath,
TextWriteMethod  write 
) [inline, static]

Wraps a delegate write method to ensure that any exception thrown during the write process does not corrupt the original file.

SafeWriteText is a convenience method around SafeWrite for writing text output. It provides a StreamWriter to the delegate and ensures that the writer is flushed and closed after the delegate returns control. SafeWrite

Parameters:
destinationPath Output location for the written file.
write Delegate to perform the specific writing.

Property Documentation

XmlWriterSettings CSharpUtilities::FileUtilities::XmlWriterSettings [static, get, set]

Recommended file settings for xml files written by the application.


CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities
CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities CSharpUtilities::FileUtilities