Class WriteLineFile
Helper used in writing to files, line by line.
It uses the fist line of a file as a column line, if one is passed.
Column names must be right padded with spaces according to a used line format.
A file may grow up to a defined maximum size (in kilobytes).
After that a new file is created.
The new file gets a name as yyyy-MM-dd_HH_mm_ss__fff_DefaultFileName
public class WriteLineFile
- Inheritance
-
WriteLineFile
- Inherited Members
- Extension Methods
Constructors
WriteLineFile(string, string, string, int)
Constructor
public WriteLineFile(string Folder = "", string DefaultFileName = "", string ColumnLine = "", int MaxSizeKiloBytes = 512)
Parameters
FolderstringThe folder where files are placed.
DefaultFileNamestringA file name to be used as template file name. A date-time value is added in front of each new file name, i.e.
yyyy-MM-dd_HH_mm_ss__fff_DefaultFileNameColumnLinestringThe first line of a file may contain column names, as passed by this parameter. Column names must be right padded with spaces according to a used line format.
MaxSizeKiloBytesintA file may grow up to a defined maximum size (in kilobytes). After that a new file is created.
Properties
ColumnLine
The first line of a file may contain column names, as passed by this parameter. Column names must be right padded with spaces according to a used line format.
public string ColumnLine { get; }
Property Value
DefaultFileName
It is the file name of the file path specified in the constructor.
public string DefaultFileName { get; }
Property Value
Folder
The folder where files are placed. It is the folder of the file path specified in the constructor.
public string Folder { get; }
Property Value
LastFileName
The current file. Its file name looks like yyyy-MM-dd_HH_mm_ss__fff_DefaultFileName.
public string LastFileName { get; }
Property Value
LastFilePath
The full path to the current file, i.e. Folder + LastFileName
public string LastFilePath { get; }
Property Value
MaxSizeKiloBytes
The maximul allowed file size.
public int MaxSizeKiloBytes { get; set; }
Property Value
Size
The size in bytes of the current file.
public int Size { get; }
Property Value
Methods
BeginFile()
Starts a new file.
protected void BeginFile()
DeleteFilesOlderThan(int)
Deletes files found in Folder older than a specified number of days.
public void DeleteFilesOlderThan(int Days)
Parameters
Daysint
WriteLine(string)
Writes a line to the LastFilePath file.
public void WriteLine(string Line)
Parameters
Linestring