TextFile.ReadToTable

table TextFile.ReadToTable ( 

string Filename )

Example 1

text_table = TextFile.ReadToTable(_SourceFolder .. "\\Information.txt");

Reads the contents of the file "Information.txt" and stores each line in the table "text_table."

Note: _SourceFolder is a built-in variable that contains the path to the folder where the setup.exe file is located.

Example 2

-- Read the contents of a text file to a table.
text_contents = TextFile.ReadToTable("C:\\MyFile.txt");

-- Get the error code of the last action.
error = Application.GetLastError();

-- If an error occurred, display the error code message.
if (error ~= 0) then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
    -- Remove the second item in the table (second line in the text file).
    Table.Remove(text_contents, 2);

    -- Write out the modified text file.
    TextFile.WriteFromTable("C:\\MyFile.txt", text_contents, false);

    -- Get the error code of the last action.
    error = Application.GetLastError();
    -- If an error occurred, display the error code message.
    if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    end
end

Reads the contents of a text file to a table. The second table entry (second line) is then removed and written back to the text file overwriting its current contents.

See also:  Related Actions