using Microsoft.Win32;
...
OpenFileDialog dlg = new OpenFileDialog();
// Filter by Office Files
dlg.Filter = "Office Files|*.doc;*.xls;*.ppt";
dlg.ShowDialog();
引用
string ProcessName="explorer";//这里换成你需要删除的进程名称
Process[] MyProcess1=Process.
GetProcessesByName(ProcessName);
Process MyProcess=new Process();//设定程序名 MyProcess.StartInfo.FileName="cmd.exe";
//关闭Shell的使用
MyProcess.StartInfo.UseShellExecute=false;
//重定向标准输入
MyProcess.StartInfo.RedirectStandardInput=true;
//重定向标准输出
MyProcess.StartInfo.RedirectStandardOutput=true;
//重定向错误输出
MyProcess.StartInfo.RedirectStandardError=true;
//设置不显示窗口
MyProcess.StartInfo.CreateNoWindow=true;
//执行强制结束命令
MyProcess.Start();
MyProcess.StandardInput.WriteLine(
"ntsd -c q -p "+(MyProcess1[0].Id).ToString());//直接结束进程ID MyProcess.StandardInput.WriteLine("Exit");
第二种,通过强大的进程类进行标准关闭。
string ProcessName="explorer";//换成想要结束的进程名字 Process[] MyProcess=Process.
GetProcessesByName(ProcessName);MyProcess[
0].Kill();
// Get the path that stores user documents.
string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
C#拷贝文件夹及文件 收藏
private void CopyDir(string srcPath, string aimPath)
{
try
{
// 检查目标目录是否以目录分割字符结束如果不是则添加之
if (aimPath[aimPath.Length - 1] != System.IO.Path.DirectorySeparatorChar)
{
aimPath += System.IO.Path.DirectorySeparatorChar;
}
// 判断目标目录是否存在如果不存在则新建之
if (!System.IO.Directory.Exists(aimPath))
{
System.IO.Directory.CreateDirectory(aimPath);
}
// 得到源目录的文件列表,该里面是包含文件以及目录路径的一个数组
// 如果你指向copy目标文件下面的文件而不包含目录请使用下面的方法
// string[] fileList = Directory.GetFiles(srcPath);
string[] fileList = System.IO.Directory.GetFileSystemEntries(srcPath);
// 遍历所有的文件和目录
foreach (string file in fileList)
{
// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
if (System.IO.Directory.Exists(file))
{
CopyDir(file, aimPath + System.IO.Path.GetFileName(file));
}
// 否则直接Copy文件
else
{
System.IO.File.Copy(file, aimPath + System.IO.Path.GetFileName(file), true);
}
}
}
catch (Exception e)
{
throw;
}
}