Click here to Skip to main content
16,004,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the below code I want to copy the file name of each file in the loop
to a new text file..

foreach (FileInfo FI in FileList)
         {
             Console.WriteLine(FI.FullName);
             Console.WriteLine(FI.LastWriteTime.ToShortDateString());
             string dt = FI.LastWriteTime.ToShortDateString();
             if(DateTime.Now.ToShortDateString()== dt)
             {
                 readfile(FI);
             }
             Console.WriteLine(dt);
         }


Please help :)

[Edit]Unchecked "Ignore HTML in text"[/Edit]
Posted
Updated 14-Jan-11 18:44pm
v6
Comments
Sergey Alexandrovich Kryukov 14-Jan-11 13:00pm    
Contradiction in question and code. "readfile(FI)" is read, not write. What does this mean "to copy the file name of each file in the loop to a new text file"? Remove old contents of files? Append file name? Create only one new file with all the names? Where is that new file?
Eager2Lern 14-Jan-11 13:08pm    
Actually what i am doing is that i am inserting the data in each file into a table in the database...So i want to copy the file name of each file in the loop to a new text file so that the next time the loop is excuted it should check the file name with the names in the text file so that duplicate data's are not inserted

1 solution

This MSDN example shows you how to write to a text file:

http://msdn.microsoft.com/en-us/library/6ka1wd3w.aspx[^]

So instead of echoing the results to the console, you write to the file.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900