You can try something like this, put attention to the comments
Code Snippet
void Form3_Load(object sender, EventArgs e)
{
//read content from the txt file
string[] lines = System.IO.File.ReadAllLines(@"c:\path.txt");
//retrieve file path from the second row
string path = lines[1];
//count files in a folder
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path);
int filesCouunt = dir.GetFiles().Length;
this.label1.Text = "There're " + filesCouunt.ToString() + " files" ;
//pass folder name and current time to listview
string name = dir.Name;
DateTime time = DateTime.Now;
ListViewItem item = new ListViewItem(new string[]{
name,time.ToString(),filesCouunt.ToString()});
this.listView1.Items.Add(item);
this.listView1.Columns.Add("directory name");
this.listView1.Columns.Add("time");
this.listView1.Columns.Add("file count");
this.listView1.View = View.Details;
this.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
}
| André Dani wrote: |
|
and it can be more than one path..?
| |
what do you mean of this?
|