我有这条线:
Directory.Delete(outputfiles, true);
Run Code Online (Sandbox Code Playgroud)
如果我将其设置为true那么它也应该删除子目录和文件.现在我检查了该目录是否为空,因此下次将删除该目录.但在此目录中的异常之前,我有另外4个子目录,其中一个我有一个大约7 Mb大小的zip文件.
System.IO.IOException was unhandled
HResult=-2147024751
Message=The directory is not empty.
Source=mscorlib
StackTrace:
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at Diagnostic_Tool_Blue_Screen.CreateDirectories.CreateDirectoriesAtConstructor() in d:\C-Sharp\Diagnostic Tool Blue Screen\Diagnostic Tool Blue Screen\Diagnostic Tool Blue Screen\CreateDirectories.cs:line 35
at Diagnostic_Tool_Blue_Screen.Form1..ctor() in d:\C-Sharp\Diagnostic Tool Blue Screen\Diagnostic Tool Blue Screen\Diagnostic Tool Blue Screen\Form1.cs:line 125
at Diagnostic_Tool_Blue_Screen.Program.Main() in d:\C-Sharp\Diagnostic Tool Blue Screen\Diagnostic Tool Blue Screen\Diagnostic Tool Blue Screen\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
private void SysInfo32()
{
Process proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = "systeminfo.exe";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.Arguments = "systeminfo.exe>" + "\"" + contentDirectory + "\\systeminfo.txt" + "\"";
proc.Start();
proc.WaitForExit();
proc.Close();
}
Run Code Online (Sandbox Code Playgroud)
contentDirectory是:C:\ Users\bout0_000\AppData\Local\Diagnostic_Tool_Blue_Screen\Diagnostic Tool Blue Screen\SF_28-07-13
我希望systeminfo.txt在里面:SF_28-07-13
但该文件永远不会在此目录中创建.
我使用的参数与msinfo32.exe和使用Msinfo.exe时的参数相同
private void MsInfo()
{
Process proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = "msinfo32.exe";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.Arguments = "/nfo " + "\"" + contentDirectory + "\\msinfo.nfo" + "\"";
proc.Start();
proc.WaitForExit(); …Run Code Online (Sandbox Code Playgroud) 我想自动获取目录:user\mydocuments
所以我做了:
t = Environment.GetEnvironmentVariable(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
Run Code Online (Sandbox Code Playgroud)
但是一直t都是null.
我如何使用folderbrowserdialog?
我希望用户能够选择他想要的任何目录.
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
DialogResult result1;
result1 = new DialogResult();
folderBrowserDialog1. = "Select New Folder To Collect Files";
if (result1 == DialogResult.OK)
{
}
else
{
}
}
else
{
}
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做 ?