using System.IO;
using System.Text;
namespace MfGames.IO.Extensions
{
///
/// Useful extension methods for FileInfo.
///
public static class FileInfoExtensions
{
///
/// Reads all the text from a FileInfo object.
///
/// The file to read from.
/// The text contents.
public static string ReadAllText(this FileInfo file)
{
return File.ReadAllText(file.FullName);
}
///
/// Reads all the text from a FileInfo object.
///
/// The file to read from.
/// The encoding to use.
/// The text contents.
public static string ReadAllText(this FileInfo file, Encoding encoding)
{
return File.ReadAllText(file.FullName, encoding);
}
///
/// Writes out all the text to the given file.
///
/// The file to write to.
/// The text to write out.
public static void WriteAllText(this FileInfo file, string text)
{
File.WriteAllText(file.FullName, text);
}
///
/// Writes out all the text to the given file.
///
/// The file to write to.
/// The text to write out.
/// The encoding to use.
public static void WriteAllText(
this FileInfo file,
string text,
Encoding encoding)
{
File.WriteAllText(file.FullName, text, encoding);
}
}
}