文件下载不起作用 [英] File download not working

查看:86
本文介绍了文件下载不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在一台服务器上托管了asp.net应用程序(假定服务器名称为A).

文档位置在另一台服务器上.(假设服务器名称为B).


用户可以上传文件并成功保存在服务器B文档位置.

但是当他们尝试下载文件时未找到消息,我们来了.但是文件位于该位置,我可以通过IE通过文件路径访问服务器A.


以下是检查文件是否存在的代码.

I have hosted asp.net application in One server (assume Server name A).

The document location is on another Server.(assume Server name B).


Users can upload the files and successfully saving in Server B Document Location.

But when they trying to download file not found message us coming.But file is there in the location and i can access server machine A through IE with the file path.


Below is the Code to check the file there or not .

If Not filepath Is Nothing Then
    If File.Exists(filepath) Then
'Download Code
    else
        Message " file not found"
    end if
end if



如果是正确的问题,请告知文档文件夹需要赋予哪些权利.


请有人帮我解决这个问题..



If it is right issue ,please advice what are the rights need to give for the document folder .


Please some one help me to slove this issue..

推荐答案



是的,您必须对要上传文件的文件夹位置授予权限,否则File.Exists函数将始终返回false.我已经遇到了这个问题,并且使用了具有管理员权限的用户.授予权限后,效果很好.
Hi,

Yes, you have to give permission on the folder location where your files are being uploaded, otherwise File.Exists function will always return false. I had faced this issue and I had used a user with having administrator rights. After giving permission it worked well.


尝试执行以下操作:

Try doing this:

if (Not string.IsNullOrEmpty(filepath)) Then
    if (File.Exists(Page.MapPath(filepath)) Then
        ' download code
    else
        ' error
    end if
end if



顺便说一句,我几乎肯定您不需要查看文件路径是否为空/空,因为如果找不到文件,则File.Exists返回false,并且找不到空文件名.



BTW, I''m almost positive that you don''t need to see if the filepath is null/empty, because File.Exists returns false if the file isn''t found, and an empty filename won''t be found.


这篇关于文件下载不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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