Table of Contents

Class WriteLineFile

Namespace
Tripous.Logging
Assembly
Tripous.Logging.dll

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

Folder string

The folder where files are placed.

DefaultFileName string

A 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_DefaultFileName

ColumnLine string

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.

MaxSizeKiloBytes int

A 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

string

DefaultFileName

It is the file name of the file path specified in the constructor.

public string DefaultFileName { get; }

Property Value

string

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

string

LastFileName

The current file. Its file name looks like yyyy-MM-dd_HH_mm_ss__fff_DefaultFileName.

public string LastFileName { get; }

Property Value

string

LastFilePath

The full path to the current file, i.e. Folder + LastFileName

public string LastFilePath { get; }

Property Value

string

MaxSizeKiloBytes

The maximul allowed file size.

public int MaxSizeKiloBytes { get; set; }

Property Value

int

Size

The size in bytes of the current file.

public int Size { get; }

Property Value

int

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

Days int

WriteLine(string)

Writes a line to the LastFilePath file.

public void WriteLine(string Line)

Parameters

Line string