首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

Illegal characters in path,该如何处理

2012-10-12 
Illegal characters in pathusing Systemusing System.Collections.Genericusing System.Linqusing Sys

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)


谁能帮忙看一下?

[解决办法]

探讨

()不能用在路径中。

热点排行