简体   繁体   English

如何使用WCF Web服务将文件从网络路径复制到本地位置?

[英]How to copy file from network path to local location with WCF Webservice?

My webservice is attempting to do a file copy from a network path (\\myserver\\data\\file.dat) to a local location (C:\\temp\\file.dat). 我的Web服务正在尝试将文件从网络路径(\\ myserver \\ data \\ file.dat)复制到本地位置(C:\\ temp \\ file.dat)。

File.Copy(NetworkPath, LocalPath, true);

However I am getting the following exception when I test my code using WCF Test Client. 但是,当我使用WCF测试客户端测试代码时,出现以下异常。

Access to the path '\\myserver\\data\\file.dat' is denied. 拒绝访问路径“ \\ myserver \\ data \\ file.dat”。

How to resolve this error? 如何解决这个错误?

If you're using IIS, you need to make sure that the user which is set up for the application pool that your WCF service is using has proper access rights to the folder (write access in this case). 如果使用的是IIS,则需要确保为WCF服务正在使用的应用程序池设置的用户具有对该文件夹的正确访问权限(在这种情况下为写访问)。

You may need to replace the default user with another one that you should create for that purpose as the default user has limited access to file system. 您可能需要为此目的创建的另一个用户替换默认用户,因为默认用户对文件系统的访问受到限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM