读书人

Illegal characters in path,该如何处

发布时间: 2012-10-12 10:17:04 作者: rapoo

Illegal characters in path
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)


谁能帮忙看一下?

[解决办法]

探讨

()不能用在路径中。

读书人网 >C#

热点推荐