|
-
August 20th, 2009, 02:53 AM
#1
File.ReadAllLines Question
I have the following that i'm tryingto search one directory and all files with a string value below. The problem is that it keeps returning that it could 'Could not find file 'U:\System.IO.FileInfo[]'.'. The string directory does exist as a valid path. any ideas?
/*
string logdir = (string)Key.GetValue("LogDirectory");
string directory = logdir;
DirectoryInfo dirinfo = new DirectoryInfo(directory);
System.IO.FileInfo[] files = dirinfo.GetFiles("*.txt");
foreach (FileInfo fi in files)
{
sw.WriteLine(fi.Name, fi.Extension);
foreach (string line in File.ReadAllLines(files.ToString()))
{
if (line.Contains("crap"))
sw.WriteLine(fi + "contains" + line.ToString() + Environment.NewLine);
}
}
/*
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|