//Process proc = new Process();
//try
//{
// proc.StartInfo.FileName = "cmd.exe";
// proc.StartInfo.UseShellExecute = false;
// proc.StartInfo.RedirectStandardInput = true;
// proc.StartInfo.RedirectStandardOutput = true;
// proc.StartInfo.RedirectStandardError = true;
// proc.StartInfo.CreateNoWindow = true;
// proc.Start();
// // 去除后面\\
// String subFile = file.Substring(0, file.Length - 1);
// // 共享文件夹的密码 用户名
// string dosLine = @"net use " + subFile + " 密码" + " /User:" + "用户名";
// proc.StandardInput.WriteLine(dosLine);
// proc.StandardInput.WriteLine("exit");
// while (!proc.HasExited)
// {
// proc.WaitForExit(1000);
// }
// string errormsg = proc.StandardError.ReadToEnd();
// Console.WriteLine("导出失败:" + errormsg);
// proc.StandardError.Close();
//}
//catch (Exception ex)
//{
// Console.WriteLine("导出失败:" + ex.Message);
//}
//finally
//{
// proc.Close();
// proc.Dispose();
//}
C#导出文件到带有密码的共享文件夹
于 2023-04-03 11:35:01 首次发布