C#中的通配符 [英] Wildcard in C#
本文介绍了C#中的通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将所有文本文件添加到文件夹Source中,但是在运行代码时出现异常错误.
我用过:
Hi,
I am trying to add all text files in folder Source but get an exception error when I run the code.
I have used:
String sFile = "@c:\\Source\\*.txt";
任何帮助都会很棒.
在此先感谢:confused:
Trot
Any help would be great.
Thanks in advance:confused:
Trot
推荐答案
不好解决的一个问题是,您使用的是"@"系统,其本质上是忽略特殊字符并将所有内容视为字符串文字".所以这意味着...
Trot one problem is that you are using the "@" system which essentially means "ignore special characters and treat everything as a string literal". So what this means is...
string sFile = @"c:\Source\*.txt";
应该解决您的第一个问题.或者,您可以删除"@"并保留所有内容.
Dave
Should fix your first issue. Alternatively, you can remove the "@" and leave everything the same.
Dave
无法添加注释.收到一些服务器错误,因此可以发布作为答案.
基于对答案的评论:
看来您没有遵循David的建议.
可以使用:
Unable to add comments. Getting some server error so posting as an answer.
Based on the comment to the answer:
Looks like you did not follow what David suggested.
Either use:
string sFile = @"c:\Source\*.txt";
或
OR
string sFile = "c:\\Source\\*.txt";
这篇关于C#中的通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文