/// <summary> /// 获取文件夹属性,信息还是FileProperties里的东西。 /// </summary> /// <param name="fullName">文件全名</param> /// <returns>文件夹属性</returns> public static FileProperties GetDirectoryProperty(string fullName) { FileProperties fpro = new FileProperties(); try { DirectoryInfo dirInfo = new DirectoryInfo(fullName); fpro.Attributies = dirInfo.Attributes.ToString(); fpro.CreationTime = dirInfo.CreationTime.ToString(); fpro.Extension = dirInfo.Extension; fpro.LastAccessTime = dirInfo.LastAccessTime.ToString(); fpro.LastWriteTime = dirInfo.LastWriteTime.ToString(); fpro.Length = ""; fpro.Name = dirInfo.Name; } catch { fpro.Attributies = ""; fpro.CreationTime = ""; fpro.Extension = ""; fpro.LastAccessTime = ""; fpro.LastWriteTime = ""; fpro.Length = ""; fpro.Name = ""; } return fpro; }
/// <summary> /// 获取文件属性 /// </summary> /// <param name="fullName">文件全名</param> /// <returns>文件属性</returns> public static FileProperties GetFileProperty(string fullName) { FileProperties fpro = new FileProperties(); try { FileInfo fileInfo = new FileInfo(fullName); fpro.Attributies = fileInfo.Attributes.ToString(); fpro.CreationTime = fileInfo.CreationTime.ToString(); fpro.Extension = fileInfo.Extension; fpro.LastAccessTime = fileInfo.LastAccessTime.ToString(); fpro.LastWriteTime = fileInfo.LastWriteTime.ToString(); fpro.Length = Deal.FormatFileLength(fileInfo.Length); fpro.Name = fileInfo.Name; } catch { fpro.Attributies = ""; fpro.CreationTime = ""; fpro.Extension = ""; fpro.LastAccessTime = ""; fpro.LastWriteTime = ""; fpro.Length = ""; fpro.Name = ""; } return fpro; }
public FileProperties(FileProperties fileProperties) { this.name = fileProperties.name; this.length = fileProperties.length; this.creationTime = fileProperties.creationTime; this.lastWriteTime = fileProperties.lastWriteTime; this.lastAccessTime = fileProperties.lastAccessTime; this.attributies = fileProperties.attributies; this.extension = fileProperties.extension; }
public FileProperties(FileProperties fileProperties) { this.name = fileProperties.name; this.length = fileProperties.length; this.creationTime = fileProperties.creationTime; this.lastWriteTime = fileProperties.lastWriteTime; this.lastAccessTime = fileProperties.lastAccessTime; this.attributies = fileProperties.attributies; this.extension = fileProperties.extension; }
private void SetFile(FileProperties properties) { this.pnlPic.Visible = false; if (this.picPreview.Image != null) this.picPreview.Image.Dispose(); this.dblProList.Items.Clear(); this.dblProList.Columns.Clear(); ColumnHeader property = new ColumnHeader(); property.Text = "文件属性"; property.Width = 200; this.dblProList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { property}); ListViewItem[] items = new ListViewItem[14]; items[0] = new ListViewItem("文件名:"); items[1] = new ListViewItem("name"); items[2] = new ListViewItem("文件大小:"); items[3] = new ListViewItem("length"); items[4] = new ListViewItem("创建时间:"); items[5] = new ListViewItem("creationTime"); items[6] = new ListViewItem("修改时间:"); items[7] = new ListViewItem("lastWriteTime"); items[8] = new ListViewItem("最近访问时间:"); items[9] = new ListViewItem("lastAccessTime"); items[10] = new ListViewItem("文件属性:"); items[11] = new ListViewItem("attributies"); items[12] = new ListViewItem("文件类型:"); items[13] = new ListViewItem("extension"); this.dblProList.Items.AddRange(items); this.dblProList.Items[1].SubItems[0].Text = properties.Name; this.dblProList.Items[3].SubItems[0].Text = properties.Length; this.dblProList.Items[5].SubItems[0].Text = properties.CreationTime; this.dblProList.Items[7].SubItems[0].Text = properties.LastWriteTime; this.dblProList.Items[9].SubItems[0].Text = properties.LastAccessTime; this.dblProList.Items[11].SubItems[0].Text = properties.Attributies; this.dblProList.Items[13].SubItems[0].Text = properties.Extension; }