using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace formula_manage.EX { /// /// Exchange.xaml 的交互逻辑 /// public partial class Exchange : Window { string Log_time = DateTime.Now.ToString("yyyy-MM-dd"); DataTable logdataTable = new DataTable(); //建立log缓存 public Exchange() { InitializeComponent(); logdataTable.Columns.Add("Name", typeof(string)); logdataTable.Columns.Add("Length", typeof(int)); LOG_file(); } private void LOG_file()//建立列表 { DirectoryInfo loginfo = new DirectoryInfo(System.Environment.CurrentDirectory + "\\Exchange"); //new文件夹 DataRow FileRow = logdataTable.NewRow(); foreach (var item in loginfo.GetFiles()) { // DataRow FileRow = logdataTable.NewRow(); FileRow["Name"] = item.Name; FileRow["Length"] = item.Length/1024; logdataTable.Rows.Add(FileRow); } gridLog.ItemsSource = logdataTable.DefaultView; // FileInfo[] logFile = loginfo.GetFiles("*.log");//生成文件夹中的文件名合集 //gridLog.ItemsSource = logFile;//加载合集 // DataRow row = logdataTable.NewRow(); //ID列 //logdataTable. = // logFile.fill() // //gridLog.DataContext = "Name"; // 显示文件名 // gridLog.ItemsSource = logFile;//加载合集 } } }