基本信息
源码名称:C# winform 仿文件浏览器 例子源码
源码大小:0.05M
文件格式:.zip
开发语言:C#
更新时间:2013-10-02
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
#endregion
using System.IO;
using System.Drawing;
namespace System.Windows.Forms.Samples
{
public class FileView
{
private string _path;
private string _name;
private long _size;
private DateTime _modified;
private DateTime _created;
private string _type;
private Icon _icon;
public FileView(string path) : this(new FileInfo(path)) { }
public FileView(FileSystemInfo fileInfo)
{
SetState(fileInfo);
}
public bool IsDirectory
{
get { return (_size == -1); }
}
private void SetState(FileSystemInfo fileInfo)
{
_path = fileInfo.FullName;
_name = fileInfo.Name;
// Check if not a directory (size is not valid)
if (fileInfo is FileInfo)
{
_size = (fileInfo as FileInfo).Length;
}
else
{
_size = -1;
}
_modified = fileInfo.LastWriteTime;
_created = fileInfo.CreationTime;
// Get Type Name
Win32.SHFILEINFO info = Win32.ShellGetFileInfo.GetFileInfo(fileInfo.FullName);
_type = info.szTypeName;
// Get ICON
_icon = System.Drawing.Icon.FromHandle(info.hIcon);
}
public string Name
{
get { return _name; }
set
{
_name = value;
}
}
public long Size
{
get { return _size; }
}
public DateTime DateModified
{
get { return _modified; }
}
public DateTime DateCreated
{
get { return _created; }
}
public string Type
{
get { return _type; }
}
public Icon Icon
{
get { return _icon; }
}
public void Update()
{
// Reset state
SetState(new FileInfo(_path));
}
public string FullName
{
get { return _path; }
}
public void Update(FileSystemInfo fsi)
{
// Reset state - name changed
SetState(fsi);
}
}
}