RemoteFileInfo.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Globalization;
  3. using System.Runtime.InteropServices;
  4. namespace WinSCP
  5. {
  6. [Guid("17FF9C92-B8B6-4506-A7BA-8482D9B0AB07")]
  7. [ClassInterface(Constants.ClassInterface)]
  8. [ComVisible(true)]
  9. public sealed class RemoteFileInfo
  10. {
  11. public string Name { get; internal set; }
  12. public char FileType { get; internal set; }
  13. public long Length { get; internal set; }
  14. public int Length32 { get { return GetLength32(); } set { SetLength32(value); } }
  15. public DateTime LastWriteTime { get; internal set; }
  16. public FilePermissions FilePermissions { get; internal set; }
  17. public bool IsDirectory { get { return (Char.ToUpper(FileType, CultureInfo.InvariantCulture) == 'D'); } }
  18. internal RemoteFileInfo()
  19. {
  20. }
  21. public override string ToString()
  22. {
  23. return Name;
  24. }
  25. private int GetLength32()
  26. {
  27. if ((Length < int.MinValue) || (Length > int.MaxValue))
  28. {
  29. throw new OverflowException(string.Format(CultureInfo.CurrentCulture, "Size {0} cannot be represented using 32-bit value", Length));
  30. }
  31. return (int) Length;
  32. }
  33. private void SetLength32(int value)
  34. {
  35. Length = value;
  36. }
  37. }
  38. }