Skip to main content

Write-File

Command Description

Specify a file path and write the content to the corresponding file. All the original content in the file will be overwritten

Command Prototype

File.WriteFile(sPath,sText,sCharset)

Parameter Description

ParameterRequiredTypeDefaultDescription
sPathTruepath'''C:\Users'''The path of the file that needs to be written. You can fill in the absolute path or use the @res "path" form to indicate the path under the res folder of the current process. The path separator must be escaped, such as "C:\Laiye RPA" or @res"Laiye RPA \Laiye RPA"
sTextTruestring""The file content to write
sCharsetTrueenum"gbk"The file encode is automatically determined when it is passed as "auto", ANSI code when it is passed as "ANSI", UTF-8 code when it is passed as "utf8", and utf-16 code when it is passed as "Unicode"

Demo

/************************************Write to file************ **************************** 
Command prototype:
File.WriteFile('''C:\Users''',"","gbk")
Input parameters:
sPath--the file path to read
sText--file content written
sCharset--file character set encoding (optional)
Outgoing parameters:
None
********************************************************************************/
Dim sPath='''C:\Users\Chance\Desktop\testFile\data.txt'''
Dim sText="RPA"
File.WriteFile(sPath,sText,"gbk")