You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.2 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Text;
namespace Estsh.Client.Common.FileManager
{
/// <summary>
/// 文件信息集合類
/// </summary>
[Serializable]
public class FileInfoAliases
{
/// <summary>
/// 文件信息類的集合
/// </summary>
public List<FileInfoAlias> Infos;
// private long _totalBytes;
/// <summary>
/// 構造函數
/// </summary>
public FileInfoAliases()
{
Infos = new List<FileInfoAlias>();
}
public long TotalBytes
{
get
{
return Infos.Sum(a => a.Size);
}
}
}
/// <summary>
/// 文件信息類
/// </summary>
[Serializable]
public class FileInfoAlias : IComparable<FileInfoAlias>
{
/// <summary>
/// 文件名稱
/// </summary>
private string _name;
/// <summary>
/// 文件大小
/// </summary>
private long _size;
/// <summary>
/// 文件最后修改時間
/// </summary>
private DateTime _lastWriteTime;
/// <summary>
/// 文件版本EXE, DLL 文件)
/// </summary>
private string _version;
/// <summary>
/// 文件名稱
/// </summary>
public string Name
{
get { return _name; }
set { _name = value; }
}
/// <summary>
/// 文件大小
/// </summary>
public long Size
{
get { return _size; }
set { _size = value; }
}
/// <summary>
/// 文件最后修改時間
/// </summary>
public DateTime LastWriteTime
{
get { return _lastWriteTime; }
set { _lastWriteTime = value; }
}
/// <summary>
/// 文件版本EXE, DLL 文件)
/// </summary>
public string Version
{
get { return _version; }
set { _version = value; }
}
#region IComparable<FileInfo> 成員
public int CompareTo(FileInfoAlias other)
{
if (null == Version || null == other.Version)
{
return LastWriteTime.CompareTo(other.LastWriteTime);
}
else if (Version.IndexOf('.') < 0 || other.Version.IndexOf('.') < 0)
{
return LastWriteTime.CompareTo(other.LastWriteTime);
}
else
{
//return Version.CompareTo(other.Version);
string[] vers = Version.Split('.');
string[] vers_other = other.Version.Split('.');
int iVer = 0, iVer_other = 0;
for (int index=0; index < vers.Length; index++)
{
iVer = Convert.ToInt32(vers[index]);
iVer_other = Convert.ToInt32(vers_other[index]);
if (iVer != iVer_other)
return iVer.CompareTo(iVer_other);
}
return iVer.CompareTo(iVer_other);
}
}
#endregion
}
}