Table of Contents

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 string

Path and name of text file to read.

Returns

string

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 string

Path and name of text file to read.

encoding Encoding

As 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 FileInfo

File 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 string

String to write to the file.

path string

Path and name of text file to write.

appendToFile bool

Boolean 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 string

String to write to the file.

path string

Path and name of text file to write.

appendToFile bool

Boolean indicating whether to append to the file. True to append, False to overwrite file.

encoding Encoding

As 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")

To top