Skip to content

format

typescript
File.WriteAllText(path, content)

class: File

description

Write the text content to the specified file path (overwrite the original content).

parameter

param_nametypedescription
pathstringThe path of the specified file.
contentstringThe text content.

return

typedescription
void

code example

javascript
function Test(file_path: string) {  
    const text_content: string = "something\r\nnew line.\r\n中文\r\n\xC0\xDE\n\t";
    try {
        File.WriteAllText(file_path, text_content);
        let content = File.ReadAllText(file_path);
        if (content.length <= 0 || content != text_content) {
            Debug.Error("File '", file_path, "' has been written something, but the content is blank.");
        }
    } catch (error) {
	    Debug.Error(error);
    }
}