TX Text Control .NET Server

SaveText Method

Method|Introduced in 21.0
Namespace
TXTextControl.Web
Package
None: the TX Text Control .NET Server setup installs it, for .NET Framework.
Assembly
TXTextControl.Web.dll

Description

Saves the complete contents of a document with the specified format.

Syntax

SaveText(String, Web.StreamType)

Saves the complete contents of a document in the specified file with the specified format.

public void SaveText(string path,  Web.StreamType streamType);
ParameterDescription
path

Specifies a file into which the data is saved. If the file does not exist it is created. If the file exists its contents are overwritten.

streamType

Specifies one of the StreamType values.

SaveText(System.IO.FileStream, Web.StreamType)

Saves the complete contents of a document in the specified file stream with the specified format.

public void SaveText(System.IO.FileStream fileStream,  Web.StreamType streamType);
ParameterDescription
fileStream

Specifies a file into which the data is saved. The data is saved at the stream's current position.

streamType

Specifies one of the StreamType values.

SaveText(Byte[], Web.BinaryStreamType)

Saves the complete contents of a document in the specified byte array with the specified format.

public void SaveText(out byte[] binaryData, Web.BinaryStreamType binaryStreamType);
ParameterDescription
binaryData

Specifies a byte array into which the data is saved. No memory needs to be allocated through the caller.

binaryStreamType

Specifies one of the BinaryStreamType values.

SaveText(String, Web.StringStreamType)

Saves the complete contents of a document as a string with the specified format.

public void SaveText(out string stringData, Web.StringStreamType stringStreamType);
ParameterDescription
stringData

Specifies a string into which the data is saved. No memory needs to be allocated through the caller.

stringStreamType

Specifies one of the StringStreamType values.

Examples

SaveText is not exposed by the current ASP.NET Core editor helper. The following example uses LoadText in the current server-side setup instead.

var result = textControl.LoadText(@"App_Data\document.docx", TXTextControl.Web.StreamType.PlainAnsiText);
Console.WriteLine(result);