Hi, I want to process multiple text files within a directory and then after processing i want to store the processed files within another directory.
Below is the code which i have written. It is accessing multiple text files within a directory, applying some processing on each text file (i.e., reading 2nd value of first 10 lines). But i am not able to separately store the processed result in another directory.
static void Main(string[] args)
{
DirectoryInfo di = new DirectoryInfo(@"F:\abc\");
FileInfo[] files = di.GetFiles("*.txt");
foreach (FileInfo fri in files)
{
using (StreamReader streamReader = fri.OpenText())
{
string line;
for (int count = 0; count < 10; count++)
{
line = streamReader.ReadLine();
string[] items = line.Split(' ');
float myInteger = float.Parse(items[1]);
//Problem is here now, which path should i provide in stream writer?
StreamWriter file = new StreamWriter(@"F:\test.txt", true);
file.WriteLine(myInteger);
file.Close();
}
}
}
}