c# - Process.start 在网络驱动器上,要求身份验证

标签 c# windows-authentication file-sharing windows-networking shared-resource

考虑这段代码:

    Process process = new Process();
    process.StartInfo.FileName = "explorer";
    process.StartInfo.Arguments = "\\some_network_host\path";
    process.Start();

我想连接到共享资源并在 Explorer.exe 中打开路径,但是用户可能尚未通过身份验证。如果用户未经过身份验证,我想打开一个 Windows 身份验证弹出窗口,就像我运行 \\some_network_host\path 时看到的那样,但是,我的实际代码只是打开“My Document”(如果用户尚未经过身份验证)。如果用户已通过身份验证,则会打开显示共享资源的 explorer.exe 窗口。 谢谢。

最佳答案

这段代码对我来说效果很好

Process process = new Process();
process.StartInfo.FileName = @"\\existing_network_host\path";
process.StartInfo.UseShellExecute = true;
process.StartInfo.ErrorDialog = true; 
process.Start();

关键的区别是 StartupInfo.ErrorDialog 的真实值

关于c# - Process.start 在网络驱动器上,要求身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30238249/

相关文章:

asp.net-mvc-5 - Windows 身份验证在 ASP.NET MVC 5 Web 应用程序中不起作用

sql-server - 不在域中时使用 Windows 凭据通过 Management Studio 连接到 SQL Server

c# - 为什么这不会将正确的字节写入文件?

node.js - iis作为反向代理: configure it to forward current windows loged user as a custom header

c# - 使用泛型创建可重用的 Control 基类

iphone - 如何将sqlite3数据库文件存放在应用程序的Library目录下?

linux - 多个文件上的虚拟文件系统

macos - 为什么当我执行 SSHFS 时目录会消失?如何在 Mac OSX 10.9 上设置 SSHFS 共享?

c# - Form.Show() 挂起新的表单实例

c# - XML 到 Excel (2007) 使用 Windows XP 和 C#.Net 的想法