I want to read in a text file, but I know only part of the file name. To be more specific, the file format is "FOO_yyyymmdd_hhmmss.txt", but when I start my program I will only know "FOO_yyyymmdd_" and ".txt". In other words, I want to read this file based only on the date, ignoring the "hhmmss" (time) part, because I will not know the time of this file, but only the date.
Here is part of what I have so far:
ArrayList al = new ArrayList();
string FileName = "FOO_" + DateTime.Now.ToString("yyyymmdd") + "_" ;
string InPath = @"\\myServer1\files\";
string OutPath = @"\\myServer2\files\";
string InFile = InPath + FileName;
string OutFile = OutPath + @"faceOut.txt";
using (StreamReader sr = new StreamReader(InFile))
{
string line;
while((line = sr.ReadLine()) != null)
{
al.Add(line);
}
sr.Close();
}
How can I read this file without knowing the whole chain in advance?
source
share