using System; using System.IO; using System.Windows.Forms; namespace Archives_Center { public partial class LogDetail : Form { string folderPath = Path.GetTempPath() + @"ArchivesCenter\Data\" + Properties.Settings.Default.current_user + @"\" + Properties.Settings.Default.selectedYText + @"\" + Properties.Settings.Default.selectedMText + @"\" + Properties.Settings.Default.selectedDText + @"\"; public LogDetail() { InitializeComponent(); string[] imageFiles = Directory.GetFiles(folderPath, "*.jpg"); listView1.Columns.Add("文件名", 300); listView1.Columns.Add("大小 (KB)", 125); listView1.Columns.Add("创建时间", 150); PopulateListView(folderPath); using (StreamReader sr = new StreamReader(Path.GetTempPath() + @"ArchivesCenter\Data\" + Properties.Settings.Default.current_user + @"\" + Properties.Settings.Default.selectedYText + @"\" + Properties.Settings.Default.selectedMText + @"\" + Properties.Settings.Default.selectedDText + @"\" + "text.txt")) { string firstLine = sr.ReadLine(); label1.Text = firstLine; string secondLine = sr.ReadLine(); label2.Text = secondLine; string thirdLine = sr.ReadLine(); label3.Text = thirdLine; } using (StreamReader sr = new StreamReader(Path.GetTempPath() + @"ArchivesCenter\Data\" + Properties.Settings.Default.current_user + @"\" + Properties.Settings.Default.selectedYText + @"\" + Properties.Settings.Default.selectedMText + @"\" + Properties.Settings.Default.selectedDText + @"\" + "text.txt")) { int lineNumber = 0; while (!sr.EndOfStream) { string line = sr.ReadLine(); if (lineNumber >= 3) richTextBox1.AppendText(line + Environment.NewLine); lineNumber++; } } } private void PopulateListView(string folderPath) { listView1.Items.Clear(); string[] files = Directory.GetFiles(folderPath, "*.jpg"); foreach (string file in files) { FileInfo fileInfo = new FileInfo(file); ListViewItem item = new ListViewItem(fileInfo.Name); item.SubItems.Add((fileInfo.Length / 1024).ToString()); item.SubItems.Add(fileInfo.CreationTime.ToString()); listView1.Items.Add(item); } } private void button2_Click(object sender, EventArgs e) { DeleteFolderWithAdminRights.DeleteFolder(Path.GetTempPath() + @"ArchivesCenter\Data\" + Properties.Settings.Default.current_user + @"\" + Properties.Settings.Default.selectedYText + @"\" + Properties.Settings.Default.selectedMText + @"\" + Properties.Settings.Default.selectedDText + @"\"); this.Close(); } private void listView1_DoubleClick(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { string selectedFile = listView1.SelectedItems[0].Text; string filePath = Path.Combine(folderPath, selectedFile); System.Diagnostics.Process.Start(filePath); } } private void 属性ToolStripMenuItem_Click(object sender, EventArgs e) { long totalSize = 0; foreach (string file in Directory.GetFiles(folderPath)) { FileInfo fileInfo = new FileInfo(file); totalSize += fileInfo.Length; } MessageBox.Show("日志标题:" + label1.Text + "\n日期:" + label2.Text + "\n作者:" + label3.Text + "\n占地大小:" + totalSize/1024 + "KB", label1.Text + "属性", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }