System.NotSupportedException: 不支持给定路径的格式。
写了一段上传的代码,在火狐里可以正确上传,可是在IE里就报了这样的错(如题)。代码如下:MyFileName = UpFile.PostedFile.FileName;
MyFileName.Replace('\\', '/');
//取得原始文件名
int index = MyFileName.LastIndexOf('/');
if (index>-1)
{
MyFileName = MyFileName.Substring(index + 1);
}
//保存文件到指定路径
string path = "F:\\myWeb\\up-down\\resource\\" + MyFileName;
UpFile.PostedFile.SaveAs(path);
虚心求指点 C#文件上传 --------------------编程问答-------------------- 把path的值贴出来,其实不用贴,你看这个值就会知道错在哪里,估计是这句MyFileName.Replace('\\', '/');多余了,去掉就可以, --------------------编程问答--------------------
我吧那句去掉了,可是依然和原来一样的情况 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 哼哼很好哦!真的是达人哦 --------------------编程问答-------------------- int index = MyFileName.LastIndexOf('/');
这句改为:
int index = MyFileName.LastIndexOf('\\');
--------------------编程问答-------------------- 你还是要查看path的值,否则很难看到一些细微的问题,
补充:.NET技术 , C#