C# 如果不是unins000,则匹配unins000.exe
我正在使用Inno Setup为我的应用程序a创建一个简单的设置。 我想从第二个应用程序B调用应用程序a的C# 如果不是unins000,则匹配unins000.exe,c#,regex,filenames,C#,Regex,Filenames,我正在使用Inno Setup为我的应用程序a创建一个简单的设置。 我想从第二个应用程序B调用应用程序a的unins000.exe 所以我只使用了这段代码,它非常有效: //get a new process to start ProcessStartInfo startInfo = new ProcessStartInfo(); //get the basic exe file to run (the uninstall) startInfo.FileName = installPat
unins000.exe
所以我只使用了这段代码,它非常有效:
//get a new process to start
ProcessStartInfo startInfo = new ProcessStartInfo();
//get the basic exe file to run (the uninstall)
startInfo.FileName = installPathA() + "\\unins000.exe";
//start the uninstall
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
但是在本例中,我在unins000.exe
中将其硬编码为000
我想知道的是,是否有可能使它类似于unins…exe
,它将自动检查…
上应该有哪些数字
起初我想使用RegEx
,但这只能用于已定义的字符串,对吗?或者我也可以这样使用它吗?
或者有人知道更好的方法吗?
DirectoryInfo.GetFiles()采用一种模式,允许您搜索匹配项。您所说的“自动检查”是什么意思?文件夹中可能有名为unins123.exe或unins665.exe的Unistaller,程序应该会找到它吗?如果是这样,那么应该找到它:startInfo.FileName=Directory.EnumerateFiles(installPathA(),@“unins*.exe”,SearchOption.TopDirectoryOnly).First();是的,正是我想要的:)非常感谢!太糟糕了,我不能将你的评论标记为:已回答