Back to Devexpress

TdxCustomMemData.SaveToTextFile(string) Method

vcl-dxmdaset-dot-tdxcustommemdata-dot-savetotextfile-x28-system-dot-string-x29.md

latest3.3 KB
Original Source

TdxCustomMemData.SaveToTextFile(string) Method

Saves stored data to a plain text file.

Declaration

delphi
procedure SaveToTextFile(const AFileName: string); dynamic;

Parameters

NameTypeDescription
AFileNamestring

The path to the target plain text file.

|

Remarks

Call the SaveToTextFile procedure to save stored data to a plain text file. You can call the LoadFromTextFile procedure to load data from the created file later.

To define a character used as a column separator, use the DelimiterChar property.

Important

SaveToTextFile and LoadFromTextFile procedures depend on the current locale settings. The LoadFromTextFile procedure may not be able to load a text file created on a machine with different locale settings.

To ensure that saved data is loaded correctly regardless of locale settings, use SaveToBinaryFile, SaveToStream, LoadFromBinaryFile, and LoadFromStream procedures instead.

Code Example: Copy Data Between Datasets as Plain Text

The following code example sets a semicolon as a column separator and copies data between two memory-based datasets through a plain text file.

delphi
dxMemData1.DelimiterChar := ';'; // Sets a semicolon as a column separator
  dxMemData1.SaveToTextFile(ExtractFileDir(Application.ExeName) + 'data.txt');
  dxMemData2.DisableControls; // Disables data synchronization with bound controls
  try
    dxMemData2.DelimiterChar := ';'; // Sets a semicolon as a column separator
    dxMemData2.LoadFromTextFile(ExtractFileDir(Application.ExeName) + 'data.txt');
  finally
    dxMemData2.EnableControls; // Re-enables data synchronization with bound controls
  end;
cpp
dxMemData1->DelimiterChar = ";"; // Sets a semicolon as a column separator
  dxMemData1->SaveToTextFile(ExtractFileDir(Application->ExeName) + "data.txt");
  dxMemData1->DisableControls(); // Disables data synchronization with bound controls
  try
  {
    dxMemData2->DelimiterChar = ";"; // Sets a semicolon as a column separator
    dxMemData2->LoadFromTextFile(ExtractFileDir(Application->ExeName) + "data.txt");
  }
  __finally
  {
    dxMemData2->EnableControls(); // Re-enables data synchronization with bound controls
  }

See Also

TdxCustomMemData.SaveToStream Procedure

TdxCustomMemData.SaveToBinaryFile Procedure

TdxCustomMemData.SaveToStrings Procedure

TdxCustomMemData Class

TdxCustomMemData Members

dxmdaset Unit