将asp.net中的文件移动到另一台机器上 [英] move file in asp.net to another machine

查看:66
本文介绍了将asp.net中的文件移动到另一台机器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个上传文件的项目。当用户上传文件时,该文件存储在我项目的〜\ upgradeup文件夹中。当用户输入其他信息并按更新按钮时,我尝试将文件移动到另一台机器上的共享文件夹。



代码如下:



string sourcepath = Session [SourcePath]。ToString(); //这里的完整文件路径。

string targetpath =\\otherserver \sharedFolder \+ filename;



File.Move(sourcepath,targetpath);





我收到拒绝访问错误。



我向域用户提供应用程序池标识。目标文件夹具有每个人都读/写的权限。

如果我在ISS服务器上提供一个文件夹作为目标路径,文件就会正确移动。但是我不能把它转移到另一台服务器上。



任何人都可以帮忙吗?



非常感谢。

Hi,
I have a project uploading a file. When user upload a file, the file is stored in ~\preupload folder in my project. When user enter other infos and press the "update" button, I try to move the file to shared folder on another machine.

Code like this:

string sourcepath = Session["SourcePath"].ToString(); //full file path in this.
string targetpath = "\\otherserver\sharedFolder\" + filename;

File.Move(sourcepath,targetpath);


And I'm getting "access denied" error.

I give a domain user to application pool identity. Target Folder has a "everyone read/write" permission.
And if I give a folder on the ISS server as a targetpath, file moved correctly. But I cant move it to another server machine.

Anyone help pls?

Many thanks.

推荐答案

检查目标路径文件夹权限,它应该是全局共享的。
Check the destination path folder permission, It should be globally shared for every one.


再次,



我使用system.io.file.move()方法复制文件。



如果目标文件夹是在同一台服务器上,没有错误。但是如果dest.folder在另一台服务器上,我会收到错误:

Hi again,

I use "system.io.file.move()" method to copy file.

If destination folder is in the same server, no error. But if dest.folder is in another server, i'm getting error:
Quote:

访问路径被拒绝了.--来源:mscorlib at System.IO .__ Error.WinIOError(Int32 errorCode,String maybeFullPath)

Access to the path is denied.-- Source:mscorlib at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)





例如:我的asp应用程序运行在MYSERVER上

如果是。文件夹是\\MYSERVER \ uploadedfiles \,一切都好。

但是如果是。文件夹是\\OTHERSERVER \ uploadedfiles \,访问被拒绝。



\\OTHERSERVER \ uploadedfiles \让大家阅读/写权限。为什么我收到拒绝访问错误?



感谢您的回复。



For example: My asp application run on MYSERVER
If dest. folder is "\\MYSERVER\uploadedfiles\", everthing ok.
But if dest. folder is "\\OTHERSERVER\uploadedfiles\", access denied.

"\\OTHERSERVER\uploadedfiles\" has everyone read/write permission. Why I am getting access denied error?

Thanks for your reply.


这篇关于将asp.net中的文件移动到另一台机器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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