从映射驱动器或共享文件夹中运行.NET程序 [英] Run a .NET program from a mapped drive or shared folder

查看:120
本文介绍了从映射驱动器或共享文件夹中运行.NET程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个C#Windows窗体应用程序合并在一台计算机从远程文件夹中的文件和文件夹(源文件夹是映射驱动器 - Z:\文件夹)与另一远程文件夹在不同的机器上( 目标文件夹是一个UNC路径到共享文件夹 - \\计算机名\ sharedfolder)。我有完全的权限,以这两个文件夹。当我在我的本地机器上运行的程序,它工作正常,但是当我尝试从源文件夹中运行它,它失败,安全异常。

I have written a C# Windows Forms application to merge the files and folders from a remote folder on one machine ("source" folder is a mapped drive - "Z:\folder") with another remote folder on a different machine ("destination" folder is a UNC path to a shared folder - "\\computername\sharedfolder"). I have Full permissions to both folders. When I run the program on my local machine, it works fine, but when I try to run it from from within the source folder it fails with a security exception.

未能调用DirectoryInfo的构造函数的目标文件夹时(即发生和DirectoryInfo(@\\计算机名\ sharedfolder)。我认为这个问题是因为我从映射驱动器运行的程序。任何解决方法?

The failure occurs when calling the DirectoryInfo constructor for the destination folder (i.e., DirectoryInfo(@"\\computername\sharedfolder"). I assume the problem is because I am running the program from a mapped drive. Any workarounds?

具体的例外是: 请求类型的权限'System.Security.Permissions.FileIOPermission,mscorlib程序,版本= 2.0.0.0,文化=中性公钥= b77a5c561934e089失败。

The specific exception is: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

更新

没关系,我有我的应用程序到Visual Studio 2008中(这是previously codeD于2005年),有针对性的.NET 3.5框架,编译并再次尝试。

okay, I got my application into Visual Studio 2008 (it was previously coded in 2005), targeted the .NET 3.5 framework, compiled and tried again.

我得到了完全相同的错误。

I got the exact same error.

更新 - 解决方案

我试过跟.NET 3.5,并没有工作,那么我注意到,你说3.5 SP1。该服务包是肯定需要的。

I tried it with .NET 3.5, and it didn't work, then I noticed that you said 3.5 SP1. The service pack is definately needed.

问题解决了。谢谢你。

推荐答案

<一个href="http://blogs.msdn.com/vancem/archive/2008/08/13/net-framework-3-5-sp1-allows-managed-$c$c-to-be-launched-from-a-network-share.aspx">.NET 3.5 SP1允许流失网络共享应用。 previous版本没有答应。

.NET 3.5 SP1 allows running applications off a network share. Previous versions did not allow it.

这篇关于从映射驱动器或共享文件夹中运行.NET程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆