iv尝试了许多不同的方法来使这个工作,我得到它基本工作,但我不能得到WaitForExit(); 像他们在这里一样工作......所以我如何将其转换为使用sevenzip?因为我无法让它工作,而且我的SFX是密码使得除了使用程序之外无法访问它们以及添加7z.DLL我无法添加它因为我收到错误:
无法添加对7za.dll的引用.请确保该文件是可访问的,并且它是有效的程序集或COM组件.
string tempFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
System.Diagnostics.Process defrag1 = System.Diagnostics.Process.Start(@"AusLogics_Defrag.exe", string.Format(" -o{0} -y -Pthisisthepass", tempFolder));
defrag1.WaitForExit();
string executableDirectoryName = Path.GetDirectoryName(Application.ExecutablePath);
System.Diagnostics.Process defrag2 = System.Diagnostics.Process.Start(tempFolder + "\\" + "AusLogics_Defrag" + "\\" + "DiskDefrag.exe", "");
defrag2.WaitForExit();
System.IO.Directory.Delete(tempFolder + "\\" + "AusLogics_Defrag", true);
Run Code Online (Sandbox Code Playgroud)
新:好吧这是我到目前为止,但我得到的错误"无法加载7-zip库或内部COM错误!消息:无法加载库"
SevenZipExtractor.SetLibraryPath("7z.dll"); //no idea of this is needed or not
SevenZipCompressor.SetLibraryPath("7z.dll"); //no idea of this is needed or not
string tempFolder = Environment.GerFolderPath(Environment.SpecialFolder.ApplicationData);
SevenZipExtractor defrag = new SevenZipExtractor(@"Programs\Optimize\Auslogics_Defrag.7z");
defrag.ExtracArchive(string.Format("-o{0} -y -PThisisthepass", tempFolder));
Run Code Online (Sandbox Code Playgroud) 因此,在我的注册表中,我在"LocalMachine\SOFTWARE\Microsoft\Windows\CurrentVersion\Run \"下输入名为"COMODO Internet Security"的条目,这是我的防火墙.现在我想知道的是如何让注册表检查该条目是否存在?如果它确实如此,那么这样做.我知道如何检查子项"Run"是否存在但不是"COMODO Internet Security"的条目,这是我用来获取子密钥的代码.
using (RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"))
if (Key != null)
{
MessageBox.Show("found");
}
else
{
MessageBox.Show("not found");
}
Run Code Online (Sandbox Code Playgroud) 嗨我有这个代码片段,我写了检查是否存在文件夹(仅存在于x64中),如果是这样,它执行"X"命令,如果没有(即x86)执行"Z"命令(x,Z是只是代码的标记)但我想知道是否有更好或更可靠的方法来只使用2.0 .net框架?
string target = @"C:\Windows\SysWow64";
{
if (Directory.Exists(target))
{
//do x64 stuff
}
else
{
//do x86 stuff
}
Run Code Online (Sandbox Code Playgroud) 我目前使用此代码删除文件夹及其内容:
string tempFolder = System.Environment.GetEnvironmentVariable("HomeDrive");
System.IO.Directory.Delete(tempFolder + "\\" + "Test", true);
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但它会删除文件夹及其内容,但不会删除只读文件.那么如何使用c#有针对性的Framework 2.0来完成这个呢?
我有一个标签显示显卡名称,制作和其他一些信息,我正在制作它,以便点击它时,它打开Firefox并在谷歌搜索卡的名称.
我尝试使用"让你遇到谷歌",但它会单独搜索每项工作.
这是我到目前为止所尝试的,它有点工作,但它有一些问题:
private void label13_Click(object sender, EventArgs e)
{
ManagementObjectSearcher Vquery = new ManagementObjectSearcher(
"SELECT * FROM Win32_VideoController");
ManagementObjectCollection Vcoll = Vquery.Get();
foreach (ManagementObject mo in Vcoll)
{
System.Diagnostics.Process CcleanerA = System.Diagnostics.Process
.Start(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe",
"http://google.com/?q="+(mo["name"].ToString()));
}
}
Run Code Online (Sandbox Code Playgroud)
好吧,我得到它来搜索正确的东西,但它搜索它两次,在2个标签,所以什么是错的?
private void Vcard_Click(object sender, EventArgs e)
{
ManagementObjectSearcher Vquery = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
ManagementObjectCollection Vcoll = Vquery.Get();
foreach (ManagementObject mo in Vcoll)
{
System.Diagnostics.Process.Start("http://www.google.ca/search?hl=en&q=" + mo["name"].ToString());
}
}
Run Code Online (Sandbox Code Playgroud) 嗨,我有一个问题,我有一些工作良好的代码,如我使用它的70%的计算机,但..由于某种原因,有一些是讨厌的,喜欢做这样的事情(请记住这是一个假想)
private void test_click(object sender, EventArgs e)
{
MessageBox.Show("hi");
//if it works ok without a error it continues to
MessageBox.Show("worked ok");
//if it encountered a error of some kind it would go to
MessageBox.Show("DID NOT WORK OK");
}
Run Code Online (Sandbox Code Playgroud)