【发布时间】:2021-02-03 18:29:30
【问题描述】:
我有一个用 VB.net 编写的 Windows 服务,该服务将读取一些 XML 文件并创建 gpg 加密文件。下面是实现它的代码
Dim OutputFileWithPath As String = outputFolder + "\" + xmlFile.Name + ".gpg"
Dim gpgExecutable As String = getAppSetting("GnuPGLocation") + "gpg"
Dim gpgOptions As String = " --recipient " +
getAppSetting("Recipient") + " --output """ +
OutputFileWithPath + """" + " --encrypt """ +
inputFolder + "\" + xmlFile.Name + """"
Dim pInfo As ProcessStartInfo = New ProcessStartInfo(gpgExecutable, gpgOptions)
pInfo.CreateNoWindow = True
pInfo.UseShellExecute = False
pInfo.WindowStyle = ProcessWindowStyle.Hidden
_processObject = Process.Start(pInfo)
_processObject.WaitForExit()
程序执行后,当我尝试查看输出文件夹时,我什么也看不到。但是当我运行相同的命令时,它会询问文件已经存在是否要覆盖。当我执行与控制台应用程序相同的代码时,它工作正常。但是当我将它作为 Windows 服务运行时,我遇到了这个问题。但是相同的命令适用于 D: 驱动器作为输出文件夹。文件夹的权限会不会有问题?
【问题讨论】:
-
你确定
outputFolder的值是你想要的吗?运行该服务的用户帐户是否对该目录具有写入权限?