2012-01-25 25 views
-1

我想通过点击一个按钮从网页打开文件夹... 在我的代码中,当我使用超链接时,它的工作正常。 但是当我使用一个按钮不工作。如何在新窗口中打开文件?

这里是我的代码:

protected void Button1_Click(object sender, EventArgs e) 
    { 
     Response.Redirect("file://LAP6//C$"); 

    } 

你能为我提供了一些C#代码实现此功能。 感谢

+0

[this](http://stackoverflow.com/questions/6248702/redirecting-new-tab-on-button-click-response-redirect-in-asp-net-c-sharp)可能会帮助 – 0xBADF00D

+0

退房这个页面的答案http://stackoverflow.com/questions/104601/asp-net-response-redirect-to-new-window –

回答

0

如果你只是想打开某个文件夹,那么你可以试试这个方法:

protected void Button1_Click(object sender, EventArgs e)  
{ 

System.Diagnostics.ProcessStartInfo processInfo = new System.Diagnostics.ProcessStartInfo(); 
     processInfo.FileName = "explorer.exe"; 
     processInfo.Arguments = Server.MapPath("YourFolderName"); 
     Response.Write(processInfo.Arguments.ToString()); 
     System.Diagnostics.Process.Start(processInfo); 
} 

回复我,如果你的作品。

+0

这个答案似乎忽略了这个问题是关于ASP.NET。这个答案将尝试在* server *上打开资源管理器,这不是OP想要的。 (提示:你*不能*做任何OP想要的) –

+0

**也**只是供参考:请阅读网站常见问题关于在您的文章中包含签名。我会再次将它编辑回去;请不要放回去。 http://stackoverflow.com/faq#signatures –