【问题标题】:How to create empty file with NSIS如何使用 NSIS 创建空文件
【发布时间】:2011-09-06 06:56:30
【问题描述】:

在我的安装程序中,我想创建一个空文件。在 linux 中我会使用 touch 命令,但在 NSIS 中最简单的方法是什么?

【问题讨论】:

    标签: nsis


    【解决方案1】:
    #Compile time
    !appendfile "$%temp%\compiletimefile.txt" ""
    
    ;Or if you need to force the file to be empty
    !appendfile "$%temp%\compiletimefile.txt" ""
    !delfile "$%temp%\compiletimefile.txt"
    !appendfile "$%temp%\compiletimefile.txt" ""
    
    
    #Run time, method 1
    FileOpen $0 "$temp\runtimefile1.txt" w
    FileClose $0
    
    
    #Run time, method 2
    File "/oname=$temp\runtimefile2.txt" "$%temp%\compiletimefile.txt"
    

    【讨论】:

    • 感谢您的解决方案。我不知道 !appendfile 命令。
    【解决方案2】:

    使用这个简单的代码来创建一个空文件。此外,将它放在任何功能块中对调试都有很大帮助。

    StrCpy $9 "hello world"
    FileOpen $8 "$DESKTOP\test_1.txt" w ;Opens a Empty File and fills it
    FileWrite $8 "$9"
    FileClose $8 ;Closes the filled file
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多