File.Read
Skip to content
mnscript
StringResult File.Read(string, string) 

Description ​

Reads the contents of a file.

Arguments ​

string - The directory to search.
string - The file to read.

Returns ​

StringResult - A StringResult representing the success/failure of the operation.

Example ​

msc
using File;
using Console;
using System;

// Reads "my_file.txt" in "r/documents".

StringResult result = File.Read("r/documents", "my_file.txt");

if(result.GetResult()){
    // If the file was read, the contents will be contained in the result's string.
    string fileContents = result.GetString();
}else{
    // If the file could not be read, the result string contains the reason.
    Console.WriteLine("Error: "..result.GetString());
}