我正在尝试使用2个变量(ctidSelected,type)创建一个目录:
new FileInfo(Server.MapPath("CopyFiles\\"+ctidSelected+"\\"+type)).Directory.Create();
但是创建的目录是“CopyFiles \ 1000”而不是“CopyFiles \ 1000 \ type1”,其中ctidSelected = 1000并且type = type1
答案 0 :(得分:2)
您应该调用Directory.CreateDirectory
而不是获取父目录并创建该目录:
Directory.CreateDirectory(Path.Combine(Server.MapPath("~/CopyFiles"), ctidSelected, type));
答案 1 :(得分:0)
string ctidSelected= "1000";
string type = "type1";
System.IO.Directory.CreateDirectory(Server.MapPath("CopyFiles\\"+ctidSelected+"\\"+type));