日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

NSIS FileOpen打开读写文件操作

發(fā)布時間:2023/12/19 综合教程 33 生活家
生活随笔 收集整理的這篇文章主要介紹了 NSIS FileOpen打开读写文件操作 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

打開文件 FileOpen
語法:
FileOpen user_var(handle output) filename openmode

Opens a file named "filename", and sets the handle output variable with the handle.
打開一個名為“filename”的文件,并使用句柄設(shè)置句柄輸出變量。
The openmode should be one of "r" (read) "w" (write, all contents of file are destroyed) or "a" (append, meaning opened for both read and write, contents preserved).
打開方式openmode應(yīng)該是以下值之一

r 讀取
w 寫入(會覆蓋原來的內(nèi)容)
a 追加(讀取和寫入均打開,保留了原來的內(nèi)容)

In all open modes, the file pointer is placed at the beginning of the file.
在所有打開模式下,文件指針都位于文件的開頭。
If the file cannot be opened, the handle output is set to empty, and the error flag is set.
如果無法打開文件,則將句柄輸出設(shè)置為空,并設(shè)置錯誤標(biāo)志。
If no absolute path is specified the current folder will be used. The current folder is the folder set using the lastSetOutPathinstruction.
如果未指定絕對路徑,則將使用當(dāng)前文件夾。當(dāng)前文件夾是使用最后一個SetOutPath指令設(shè)置的文件夾。
If you have not usedSetOutPaththe current folder is$EXEDIR.
如果尚未使用SetOutPath,則當(dāng)前文件夾為$ EXEDIR。

示例:

FileOpen $0 $INSTDIRfile.dat r
FileClose $0

Command introduced with NSIS v1.60


寫入文件 FileWrite
語法:
FileWrite user_var(handle) content

關(guān)閉文件 FileClose
語法:
FileClose user_var(handle)

下面是一個以寫入方式打開文件并重寫內(nèi)容的示例:

ClearErrors
FileOpen $0 "$INSTDIRNIRModelingRPFBusFrontendstaticjsBaseUrl.js" w
IfErrors done
FileWrite $0 'const BASE_URL = { url: "http://$SQL_SERVERNAME:80/NIRModelingAPI/" };const RPF_URL = { url: "http://$SQL_SERVERNAME:80/" };'
FileClose $0
done:


總結(jié):
FileOpen、FileWrite、FileClose 是三個文件操作函數(shù)。
$0 是一個變量,這里相當(dāng)于文件句柄。
注意打開文件的方式選擇,如果不需要覆蓋原文件內(nèi)容,則使用追加方式打開。

總結(jié)

以上是生活随笔為你收集整理的NSIS FileOpen打开读写文件操作的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。