web窗体如何获取到运行这个网站的本机的某一目录下的所有一级目录
1 protected void Button2_Click(object sender, EventArgs e)
2 {
3
4 string URL = TextBox3.Text;
5 try
6 {
7
8 List<string> Strs = GetAllFileName(URL);
9 int count = Strs.Count;
10
11 string content = "";
12 for (int i = 0; i < count; i++)
13 {
14 content += Strs[i].ToString() + "; ";
15 }
16 TextBox1.Text = content;
17 }
18 catch
19 {
20
21 }
22 }
23
24
25 public List<string> GetAllFileName(string url)
26 {
27
28 string str0 = url;
29 List<string> list=new List<string>();
30 try
31 {
32 DirectoryInfo info = new DirectoryInfo(str0);
33 FileSystemInfo[] files = info.GetFileSystemInfos();
34 Array arr = files.ToArray();
35 for (int i = 0; i < arr.Length; i++)
36 {
37 string Str = arr.GetValue(i).ToString();
38 list.Add(Str);
39 }
40 }
41 catch
42 {
43
44 }
45
46 return list;
47
48 }如题:web窗体如何获取到运行这个网站的本机的某一目录下的所有一级目录
我写了一段代码,可是只有在本机用VS打开运行的时候可以查到所有目录,可是部署到IIS上的时候,用ip地址来访问就获取不到了是怎么回事呢,(局域网内用一台机子来部署这个网站,另一台去访问,获取不到文件件名字)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4547/viewspace-3160450/ ,如需转载,请注明出处,否则将追究法律责任。