Class TextFileHelper
- Namespace
- Dynamicweb.Core.Helpers
- Assembly
- Dynamicweb.Core.dll
Class TextfileHelper used for reading and writing text files.
public class TextFileHelper
- Inheritance
-
TextFileHelper
- Inherited Members
Methods
ReadTextFile(string)
Returns the contents of a text file as a string.
public static string ReadTextFile(string path)
Parameters
path
stringPath and name of text file to read.
Returns
Remarks
Path must contain the physical path to the file e.g. "C:\Testfile.txt"
ReadTextFile(string, Encoding)
Read the current text file in a particular encoding.
public static string ReadTextFile(string path, Encoding encoding)
Parameters
path
stringPath and name of text file to read.
encoding
EncodingAs System.Text.Encoding, to determin a particular encoding.
Returns
- string
Returns the contents of a text file as a string.
Remarks
Path must contain the physical path to the file e.g. "C:\Testfile.txt"
TryMakeWritable(FileInfo)
Tries to make the given file writable.
public static bool TryMakeWritable(FileInfo info)
Parameters
info
FileInfoFile information (FileInfo instance).
Returns
- bool
Value indicating whether file has been successfully made writable.
WriteTextFile(string, string, bool)
Writes a string to a text file.
public static void WriteTextFile(string value, string path, bool appendToFile = false)
Parameters
value
stringString to write to the file.
path
stringPath and name of text file to write.
appendToFile
boolBoolean indicating whether to append to the file. True to append, False to overwrite file.
Remarks
Path must contain the physical file path to the file e.g. Server.Mappath("/files/filer/Testfile.txt")
WriteTextFile(string, string, bool, Encoding)
Writes a string to a text file in a particular encoding.
public static void WriteTextFile(string value, string path, bool appendToFile, Encoding encoding)
Parameters
value
stringString to write to the file.
path
stringPath and name of text file to write.
appendToFile
boolBoolean indicating whether to append to the file. True to append, False to overwrite file.
encoding
EncodingAs System.Text.Encoding, to determin a particular encoding.
Remarks
Path must contain the physical file path to the file e.g. Server.Mappath("/files/filer/Testfile.txt")