在C# asp.net中将文件写入当前用户的桌面
如果我有此代码,如果无法访问网络共享的其他用户尝试运行该方法,则会产生问题。我怎样才能让这个方法将文件写入当前用户桌面?
private void skriveTilFil()
{
StreamWriter writer = new StreamWriter(@"\\192.168.1.2\tmp\script.vbs");
writer.WriteLine(scripttbx.Text);
writer.Dispose();
}
if i have this code, this creates a problems if other user that dont have acces to the network share tryes to run the method. How can i make this method write the file to the current users desktop?
private void skriveTilFil()
{
StreamWriter writer = new StreamWriter(@"\\192.168.1.2\tmp\script.vbs");
writer.WriteLine(scripttbx.Text);
writer.Dispose();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在客户端/服务器 Web 环境中,您不应该能够直接在客户端计算机上写入数据。
您可以将一些数据下载到浏览器和/或运行安装在客户端工作站上的 ActiveXObject 吗?这可能会导致在用户计算机上安装组件时出现一些问题,但会更容易开发。
On client/server web environments, you shouldn't be able to write data directly on client machines.
Can you download some data to your browser and/or run an ActiveXObject installed on client workstation? This can lead to some issues installing components on users machines, but will be more easily developed.
您可以通过更改权限/策略在 Intranet 环境中完成此操作。您必须通过 IIS/Active Directory 向 ASP.NET 应用程序授予适当的共享权限。
You can do it in an intranet environment by altering permissions/policies. You have to give the appropriate permissions to your ASP.NET application through IIS/Active Directory to the shares.
浏览器安全性可以在不使用 ActiveX 等控件的情况下防止这种情况发生。
您不只提供下载链接有什么特殊原因吗?
Browser security prevents this without using a control such as an ActiveX.
Any particular reason you don't just provide a download link?