代码之家  ›  专栏  ›  技术社区  ›  Kyle

是否检查文件是否存在?

wix
  •  1
  • Kyle  · 技术社区  · 14 年前

    我正在尝试查看WIX是否存在文件。我尝试了以下方法:

    <Property Id="TEMPFILE" >
      <DirectorySearch Path="[TempFolder]" Depth="0" Id="TempFolderDirectorySearcher">
        <FileSearch Name="temp.txt"/>
      </DirectorySearch>
    </Property>
    

    但似乎该属性是在启动时初始化的,然后再也不会初始化。我正在创建延迟自定义操作期间的文件。在那次行动之后,最好的检查方法是什么?(或强制重新填充属性)?

    3 回复  |  直到 14 年前
        1
  •  1
  •   Christopher Painter    14 年前

        2
  •  1
  •   Kyle    14 年前

    'Set Dimension
    DIM fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    ' Set our targetFile
    DIM targetFile
    targetFile = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%Temp%")
    targetFile= tempFile & "\temp.txt"
    
    ' Check to see if our file exists
    If ( fso.FileExists( tempFile ) ) Then
        Session.Property("TempFileExists") = "TRUE"
    End If
    
        3
  •  0
  •   Yan Sklyarenko    14 年前