C# DirectoryInfo的路径问题
string[] s = Directory.GetFiles(@"D:\陈金龙实训\实训\NetShop\images\staticshop\qqq");
string[] filename = new string[s.Length];
for (int i = 0; i < s.Length; i++)
{
filename[i] = Path.GetFileName(s[i]);
}
这个GetFiles()后面这个我想要相对路径,怎么做? 我改成下面代码的相对路径,运行说路径不对
这实训要去交的,我总不能去那里手动改我自己绝对路径吧?
下面的代码 却能使用相对路径 这个是怎么回事?
(我仿照下面的相对路径的时候,没有漏掉textBox1.text的值,所以说 上面的相对路径应该是对的)
string path = "../images/staticshop/" + TextBox1.Text;
DirectoryInfo my = new DirectoryInfo(path);
if(!my.Exists)
Directory.CreateDirectory(Server.MapPath(path));
[解决办法]
相对于什么的相对路径
DirectoryInfo my = new DirectoryInfo(path);
->
DirectoryInfo my = new DirectoryInfo(Server.MapPath(path));