Class TSimpleTextNCFile
Simplest implementation of the output file. It is just wrapper around Stream
To use TSimpleTextNCFile class just create an instance of it and use Write
Also you can set the desired encoding Text
Implements
Namespace: DotnetPostprocessing .SDK
Assembly: DotnetPostprocessing.SDK.dll
Syntax
public class TSimpleTextNCFile : TNCFile, INCBlockOwner
Constructors
TSimpleTextNCFile()
Initializes a new instance of TSimpleTextNCFile object and assigns TNCFilesManager.Singletone.DefaultNCFilesOwner
as an
Owner.
It assigns UTF-8 without BOM as a desired encoding of the output file (Text
Declaration
public TSimpleTextNCFile()
TSimpleTextNCFile(INCFileOwner)
Initializes a new instance of TSimpleTextNCFile object and assigns specified object as an Owner.
It assigns new UTF8Encoding(false)
(UTF-8 without BOM) as a desired encoding of the output file (Text
Declaration
public TSimpleTextNCFile(INCFileOwner Owner)
Parameters
Type | Name | Description |
---|---|---|
INCFile |
Owner | The object that is the owner of the output file formed by the postprocessor. Usually the owner is a postprocessor itself. |
TSimpleTextNCFile(INCFileOwner, Encoding)
Initializes a new instance of TSimpleTextNCFile object and assigns specified object as an Owner. It expects the encoding of the output text file as an input parameter.
Declaration
public TSimpleTextNCFile(INCFileOwner Owner, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
INCFile |
Owner | The object that is the owner of the output file formed by the postprocessor. Usually the owner is a postprocessor itself. |
Encoding | encoding | Desired output file encoding. If it is null then default encoding of the Stream |
TSimpleTextNCFile(Encoding)
Initializes a new instance of TSimpleTextNCFile object and assigns TNCFilesManager.Singletone.DefaultNCFilesOwner
as an
Owner. It expects the encoding of the output text file as an input parameter (Text
Declaration
public TSimpleTextNCFile(Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Encoding | encoding | Desired output file encoding. If it is null then default encoding of the Stream |
Properties
OutputFileName
The file name with a full path where this output file should be saved at the finish.
Declaration
public override string OutputFileName { get; set; }
Property Value
Type | Description |
---|---|
string |
Overrides
TextEncoding
Desired encoding of the output file. For example, you can use one of the following variants.
Encoding.GetEncoding("windows-1251")
- with specifying any standard textual name of the encoding.Encoding.UTF8
- UTF-8 with BOM (byte order mark bytes at the start of a file)Encoding.Unicode
- UTF-16 using the little endian byte order.Encoding.BigEndianUnicode
- UTF-16 using the big endian byte order.Encoding.Default
- The default encoding for this .NET implementation.new UTF8Encoding(false)
- UTF-8 without BOM will be used.null
- UTF-8 without BOM will be used.
You can assign TextEncoding not only at the initialization of new instance of TSimpleTextNCFile but at any time of postprocessing. It will be applied at the finish of whole postprocessing.
Declaration
public Encoding TextEncoding { get; set; }
Property Value
Type | Description |
---|---|
Encoding |
Methods
Finalize()
Finalizes TSimpleTextNCFile instance and disposes system resources.
Declaration
protected override void Finalize()
Flush()
It should write the buffered in memory data for the output file to a hard drive (to a temporary files, not to the final destination). Usually you don't need to call it manually, the postprocessing system calls it as needed.
Declaration
public override void Flush()
Overrides
Output(string)
Writes the specified string with the line break (will be added automatically) to the end of the file.
Declaration
public void Output(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string you want to write. |
SaveToFile(string)
This method is called by the system automatically at the most final stage of the postprocessor's work.
Here the content of the file should be written from a temporary storage (in memory or temporary file)
to the destination file specified in the Output
After this saving the On
Declaration
public override void SaveToFile(string fileName)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The destination file path. |
Overrides
Write(string)
Writes the specified string to the end of the file. No line break is added.
Declaration
public void Write(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string you want to write. |
Write(string, INCLabel)
Attention! This feature doesn't supported by the TSimpleTextNCFile class. It will throw
the EPostprocessor
To be possible to use random position file writing with INCLabel use TText
Declaration
public void Write(string s, INCLabel label)
Parameters
Exceptions
Type | Condition |
---|---|
EPostprocessor |
WriteLine()
Writes the line break to the end of the file.
Declaration
public void WriteLine()
WriteLine(string)
Writes the specified string with the line break (will be added automatically) to the end of the file.
Declaration
public void WriteLine(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string you want to write. |
WriteLine(string, INCLabel)
Attention! This feature doesn't supported by the TSimpleTextNCFile class. It will throw
the EPostprocessor
To be possible to use random position file writing with INCLabel use TText
Declaration
public void WriteLine(string s, INCLabel label)
Parameters
Exceptions
Type | Condition |
---|---|
EPostprocessor |