日期:2014-05-18 浏览次数:20965 次
TreeViewItem selectedItem = (TreeViewItem)folderTreeView.SelectedItem; string selectedPath = (string)selectedItem.Tag; string[] files = Directory.GetFiles(selectedPath); this.fileListView.Items.Clear(); DataTable dataTable = new DataTable(); dataTable.Columns.Add("Name",Type.GetType("System.String")); dataTable.Columns.Add("LastModifiedTime",Type.GetType("System.String")); dataTable.Columns.Add("Size",Type.GetType("System.String")); foreach(string file in files) { FileInfo fileInfo = new FileInfo(file); string[] items= new string[] { fileInfo.Name, fileInfo.LastWriteTime.ToString(), fileInfo.Length.ToString() }; dataTable.Rows.Add(items[0], items[1], items[2]); } this.fileListView.DataContext = dataTable;