Illegal characters in path

2_fairyland 2012-09-26 11:44:04
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
namespace folderGenerater
{
class Program
{
static void Main(string[] args)
{
using (StreamReader sr = new StreamReader("E:\\TDDOWNLOAD\\u6(1).doc"))
{
ArrayList al = new ArrayList();

while (sr.Peek() != -1)
{
al.Add(sr.ReadLine());

}

for(int i = 0;i<al.Count;i++)
{

String para = al[i].ToString();
String path = @"D:\\u0926\\"+para ;

if (!System.IO.Directory.Exists(path))
try
{
System.IO.Directory.CreateDirectory(path);
}
catch (Exception e) {
Console.WriteLine(e);
}

}

}
}
}
}


报错:
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.Combine(String path1, String path2)
at Microsoft.VisualBasic.FileIO.FileSystem.GetFullPathFromNewName(String Path, String NewName, String ArgumentName)
at Microsoft.VisualBasic.FileIO.FileSystem.RenameFile(String file, String newName)
at Microsoft.VisualBasic.MyServices.FileSystemProxy.RenameFile(String file, String newName)


谁能帮忙看一下?
...全文
433 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
2_fairyland 2012-09-27
  • 打赏
  • 举报
回复
读取的源文件里面有表格,转换成纯文本后问题解决
宝_爸 2012-09-26
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

()不能用在路径中。
[/Quote]

好像可以,那应该是path中有非法字符了。
设置个断点

看看String path = @"D:\\u0926\\"+para ;后path是什么。
孟子E章 2012-09-26
  • 打赏
  • 举报
回复
@"D:\\u0926\\"+para ;

前面的@多余,不明白@的含义不要乱加
宝_爸 2012-09-26
  • 打赏
  • 举报
回复
()不能用在路径中。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧