Developer Function: Server Script: $ps.file.writeAllText
Overview¶
Used when writing a file using "$ps.file" in "Server Script". Saves all strings passed as arguments to a file. If a file with the same name exists, it will be overwritten. If there is no file with the same name, a new file will be created.
Syntax¶
Parameter¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| section | string | Yes | Section name. For details about sections, see "About Sections" in "$ps.file". |
| path | string | Yes | File name. The directory separator is "/" for both Windows and Linux. |
| data | string | Yes | String to output |
| encode | string | Specify file encoding (※1) If omitted, it will be "utf-8" |
※1
Specify the code page name that can be specified with the parameters of System.Text.Encoding.GetEncoding in the .NET library.
Return value¶
Returns true if the file can be output, false if it cannot.
Exception¶
If an exception occurs in C#, the exception class name and error message are placed in the Error object in the server script to generate an exception.
Usage example¶
The following example writes a file to the specified file name in the web server.
JavaScript¶
Character code: Example of Shift-JIS
Supported Versions¶
| Supported versions | Body |
|---|---|
| 1.4.12.0 and later | Added function |