User Manual

06.26.2025

MANUAL

Developer Function: Server Script: $ps.file.readAllText

## Overview This function is used in "[Server Script](/en/manual/table-management-server-script)" to read files using "「$ps.file」" It reads the entire content of a file and returns the value as a string. ## Prerequisites The DisableServerScriptFile setting in Script.json must be set to false. ## Syntax ``` $ps.file.readAllText(section, path, encode=null); ``` ## Parameters |Parameters|Type|Required|Description| |:----------|:----------|:---:|:---------------------------| |section|string|Yes|Section name. For details on sections, refer to the "「$ps.file」" section explanation.| |path|string|Yes|File name. Use「/」as the directory delimiter for both Windows and Linux.| |encode|string||File encoding specification (※1)Defaults to "utf-8" if omitted.| ※1 Specify the code page name supported by the System.Text.Encoding.GetEncoding parameter. ## Return Value Returns the content of the file as a string. If the file does not exist, it returns null. ## Exceptions If an exception occurs within C#, the exception class name and error message are encapsulated in an Error object and thrown within the server script. ## Usage Examples In the examples below, the content of a file on the web server is read and logged to the console. ##### JavaScript ``` let text = $ps.file.readAllText('01_develop', 'parts/01_parts.txt'); context.Log('text: ' + text); ``` Example with Shift-JIS Encoding ``` let text = $ps.file.readAllText('01_develop', 'parts/01_parts.txt', 'shift-jis'); context.Log('text: ' + text); ``` ## Supported Versions |Supported Versions|Body| |:--|:--| |1.4.12.0 or later|Added function| ## Related Information <div id="ManualList"><ul><li><a href="/en/manual/table-management-server-script">Table Management: Server Script</a><span>08.13.2024 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.