问:文件存在吗? [英] Q: file exists?

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

问题描述

你好,

我用它来打开一个excel文件:

Response.Redirect( http://myServer/Files/myFile.xls

我应该如何检查文件是否可用以摆脱错误页面。

谢谢,

吉姆。

Hello,
I am using this to open an excel file:
Response.Redirect(http://myServer/Files/myFile.xls)
How should I check if the file available first to get rid of error page.
Thanks,
Jim.

推荐答案

怎么样

if(System.IO.File.Exists(Server.MapPath(" /Files/myFile.xls"))){

Response.Redirect(" /Files/myFile.xls");

}


Karl


-

我的ASP.Net教程
http:// www.openmymind.net/

" JIM.H." <季** @ discussions.microsoft.com>在消息中写道

新闻:8A ********************************** @ microsof t.com ...
How about:
if (System.IO.File.Exists(Server.MapPath("/Files/myFile.xls"))) {
Response.Redirect("/Files/myFile.xls");
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
你好,
我用它来打开一个excel文件:
Response.Redirect( http://myServer/Files/myFile.xls )我应该如何检查文件是否可用以摆脱错误页面。
谢谢,
吉姆。
Hello,
I am using this to open an excel file:
Response.Redirect(http://myServer/Files/myFile.xls)
How should I check if the file available first to get rid of error page.
Thanks,
Jim.



完美。我还有一个问题。

Response.Redirect(" /Files/myFile.xls")打开文件,我在

地址中看到了文件名。因此,如果用户足够聪明,他们将键入并检查其他文件

名称。我该怎么办? (我顺便使用visual basic。而不是C#。)

Karl Seguin写道:
Perfect. I have one more problem.
Response.Redirect("/Files/myFile.xls") open files and I see file name in the
address bare. so if user is clever enough they will type and check other file
names. What should I do? (I am using visual basic by the way. not C#.)
"Karl Seguin" wrote:
怎么样
if(System.IO.File.Exists(Server.MapPath(" /Files/myFile.xls") ;))){
Response.Redirect(" /Files/myFile.xls");
}

Karl

- http://www.openmymind.net/

JIM.H。 <季** @ discussions.microsoft.com>在消息中写道
新闻:8A ********************************** @ microsof t.com。 ..
How about:
if (System.IO.File.Exists(Server.MapPath("/Files/myFile.xls"))) {
Response.Redirect("/Files/myFile.xls");
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
你好,
我用它来打开一个excel文件:
Response.Redirect( http://myServer/Files/myFile.xls
我应该如何检查文件是否可用以摆脱错误页面。 />谢谢,
Jim。
Hello,
I am using this to open an excel file:
Response.Redirect(http://myServer/Files/myFile.xls)
How should I check if the file available first to get rid of error page.
Thanks,
Jim.




我认为您可以将IIS配置为不提供某些文件类型。

另一个解决方案是将文件移到虚拟目录之外。


" JIM.H." <季** @ discussions.microsoft.com>在消息中写道

news:94 ********************************** @ microsof t.com ...
I think you can configure IIS to not serve up certain file types.
Another solution is to move the files outside the virtual directory.

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
完美。我还有一个问题。
Response.Redirect(" /Files/myFile.xls")打开文件,我在
中看到文件名裸露的地址。因此,如果用户足够聪明,他们将键入并检查其他
文件名。我该怎么办? (我顺便使用visual basic。而不是C#。)

Karl Seguin写道:
Perfect. I have one more problem.
Response.Redirect("/Files/myFile.xls") open files and I see file name in the address bare. so if user is clever enough they will type and check other file names. What should I do? (I am using visual basic by the way. not C#.)
"Karl Seguin" wrote:
怎么样
if(System.IO.File.Exists(Server.MapPath(" /Files/myFile.xls") ;))){
Response.Redirect(" /Files/myFile.xls");
}

Karl

- http://www.openmymind.net/

JIM.H。 <季** @ discussions.microsoft.com>在消息中写道
新闻:8A ********************************** @ microsof t.com。 ..
How about:
if (System.IO.File.Exists(Server.MapPath("/Files/myFile.xls"))) {
Response.Redirect("/Files/myFile.xls");
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
你好,
我用它来打开一个excel文件:
Response.Redirect( http://myServer/Files/myFile.xls )我应该如何检查文件是否可用以摆脱错误
页。谢谢,
吉姆。
Hello,
I am using this to open an excel file:
Response.Redirect(http://myServer/Files/myFile.xls)
How should I check if the file available first to get rid of error page. Thanks,
Jim.




这篇关于问:文件存在吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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