我有以下代码
string[] dfFileWildCards = Helper.DataFeedsWildCards.Split(',');
string[] dfOriginalFilesPath = Directory.GetFiles(Helper.DataFeedsPath).Where(file => new FileInfo(file).CreationTime.Date == DateTime.Now.Date).ToArray();
Helper.MyWriteLine("-->DataFeeds Folder: " + Helper.DataFeedsPath);
Helper.MyWriteLine("-->WildCards: " + Helper.DataFeedsWildCards);
Helper.MyWriteLine("-->There are " + dfOriginalFilesPath.Length + " files");
foreach (string filePath in dfOriginalFilesPath)
{
Helper.MyWriteLine("Checking " + filePath.ToLower());
FileInfo file = new FileInfo(filePath.ToLower());
foreach (string dfFileWildCard in dfFileWildCards)
{
if (
file.Replace(" ", "").Name.IndexOf(dfFileWildCard.Replace(" ", ""), StringComparison.OrdinalIgnoreCase) > -1
&&
file.LastWriteTime.Date == DateTime.Now.Date
)
{
filesToCopy.Add(filePath.ToLower());
Helper.MyWriteLine("---->Marked for copy " + file.Name + ".");
}
}
}
它在 d:\cnbrd\datafeeds\authorizeddatafeedfile_20121127.txt 的日志中显示错误
11/28/2012 1:27:53 AM -->DataFeeds Folder: D:\CNBRD\DataFeeds
11/28/2012 1:27:53 AM -->WildCards: Inactive
11/28/2012 1:27:53 AM -->There are 7 files
11/28/2012 1:27:53 AM Checking d:\cnbrd\datafeeds\authorizeddatafeedfile_20121127.txt
11/28/2012 1:27:53 AM Exception occured: The path is not of a legal form.
为什么会这样?