动态访问asp.net文件夹 [英] Accesing the asp.net folder dynamically
本文介绍了动态访问asp.net文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我有一个名为``reports''的asp.net文件夹,我将所有报告文件都以pdf格式放置.现在的问题是我想动态检查``reports''文件夹中是否有文件或我正在写下面的代码,但是它不起作用..
有任何想法吗?
我背后的代码
hi everyone !!
I have an asp.net folder called ''reports'', where I am placing all my reporting files in the form of pdf format..now the problem is I want to check dynamically whether the ''reports'' folder has files or not..I am writing the following code but it''s not working..
any Idea?
my code behind
DirectoryInfo fol = new DirectoryInfo(Server.MapPath(reports));
FileInfo[] finfo = fol.GetFiles();
if (finfo!= null)<--- not working
{
//-------
}
推荐答案
尝试检查/更改reports
中的路径-请记住,如果您使用Server.MapPath使用相对于当前活动ASPX文件的路径不要指定以反斜杠开头的路径.
Try checking/changing the path in reports
- bear in mind that Server.MapPath uses paths relative to the current active ASPX file if you do not specify a path starting with backslash.
这篇关于动态访问asp.net文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文