Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got a folder under which I have lot of text files (*.txt). I'm developing a web page which have to print the name of the text files with the time stamp. I'm using aspx for front-end design and C# for processing. It would be great if some guide me give the code block for C# printing the name of text files with time stamp.

Thanks in Advance
Posted
Updated 3-Jan-12 11:01am
v2

System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo("c:\\");
System.IO.FileInfo[] diar1 = dir.GetFiles();//get all list of files inside the directory
System.IO.FileInfo dra = null;

//list the names of all files in the specified directory
foreach (System.IO.FileInfo dra_loopVariable in diar1) {
dra = dra_loopVariable;
ListBox1.Items.Add(dra);
}
 
Share this answer
 
v3
Read these pages and try to mix what you have learn from there, and then write your own code :

http://www.dotnetperls.com/directory-getfiles[^]

http://www.csharp-examples.net/file-creation-modification-time/[^]

Hope it helps.
 
Share this answer
 

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