本文介绍了路径异常中的非法字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在VS2008中使用C#语言编写了一个递归函数来扫描特定驱动器中的所有文件夹。

i使用System.Io函数。

它是这里:

 private void scan(string DriveName)
{
string [] Directories = Directory.GetDirectories(DriveName);
foreach(目录中的字符串foldername)
{
scan(foldername); //递归调用
listBox1.Items.Add(foldername); //将所有内容添加到我的列表中
}
}





但我遇到问题它。当我想扫描一个文件夹中有$#%$#^ | babak%&%&#$#@ ||的驱动器时name

我遇到异常。这是路径异常中的非法字符。我怎么解决呢?

我想用非法名称扫描所有文件夹。我只想使用dot net framework classes&功能!



拜托,请将您的想法发送给我:[已删除电子邮件]

非常感谢。

解决方案




HiI wrote a recursive function in VS2008 with C# Language to scan All folders in a Specific drive.
i used System.Io Functions .
it's here:

private void scan(string DriveName)
     {
         string[] Directories = Directory.GetDirectories(DriveName);
         foreach (string foldername in Directories)
         {
             scan(foldername);                // recursive call
             listBox1.Items.Add(foldername);  // Add Everything To My List
         }
     }



but I have a Problem whit it .when i want to scan a drive that have a folder with "$#%$#^|b a b a k %&%&#$#@||" name
I encounter to a exception .that's "Illegal characters in path exception". how can i solve it?
i want to scan All Folders with illegal names.i only want to use dot net framework classes & functions !

please , send me your idea : [Email removed]
thank you very much .

解决方案




这篇关于路径异常中的非法字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 09:12