我必须卸载现有的窗口服务,然后复制 - 将新文件替换到服务位置,然后再次安装。卸载现有的窗口服务,替换新的文件,并在c#中重新安装它#
当我停止windows应用程序并单独执行它时,它工作正常。
但是,问题是做的过程中,当连续编程,
卸载
复制新文件
在拷贝安装
我被拒绝访问错误文件步骤。甚至我试图删除文件。 问题是一样的。
当我从目录中手动删除/复制粘贴时,它正在工作。
我使用:
Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory(源极路径,目标路径,TRUE);
,并从这里也试过:
ASP.NET C# Copy Directory with SubDirectories with System.IO
任何帮助将不胜感激。
在此先感谢
编辑:
我停止服务卸载之前,如:
TimeSpan timeout = TimeSpan.FromMilliseconds(5000);
var ctlr = new ServiceController();
ctlr.ServiceName = serviceName;
ctlr.Stop();
ctlr.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
result.Success = true;
卸载:
ManagedInstallerClass.InstallHelper(new string[] { "/u",service path });
更换新的文件:
安装:
ManagedInstallerClass.InstallHelper(new string[] { userName, password, servicePath });
我卸载它之前停止该服务什么的。与“WaitForStatus”。 – 2015-02-10 05:35:10