public override void DrawContents() { ClearContents(); Console.SetCursorPosition(X + 1, Y + 1); int CurrentRow = 0; foreach (string FullFilePath in TheList) { Console.SetCursorPosition(X + 1, Y + 1 + CurrentRow); string FileName = FullFilePath.Substring(FullFilePath.LastIndexOf(@"/") + 1); if (FileName.Length < Width) { Console.Write(FileName); } else { int CurrentPosition = 0; Console.Write(FileName.Substring(CurrentPosition, (Width - 1))); CurrentPosition += Width - 1; } if (++CurrentRow > Height) { break; } } }
/// <summary> /// Constructor. /// </summary> /// <param name="fullDropName"> /// Fully qualified name of a drop. /// </param> /// <param name="fileFullPath"> /// Path to the target file which is to be added to drop. The file must exist on disk at the time of invocation. /// </param> /// <param name="relativeDropPath"> /// Relative path under which to associate the file in the target drop. If null, file name of the file is used. /// </param> /// <param name="fileContentInfo"> /// Expected content hash and file length. May be left null. /// </param> public DropItemForFile(string fullDropName, string fileFullPath, string relativeDropPath = null, FileContentInfo?fileContentInfo = null) { Contract.Requires(fileFullPath != null); FullyQualifiedDropName = fullDropName; FullFilePath = Path.GetFullPath(fileFullPath); if (FullFilePath.Length >= MaxNonLongFileNameLength && !FullFilePath.StartsWith(LongFileNamePrefix)) { // this file has a long file name, need to add a prefix to it FullFilePath = $"{LongFileNamePrefix}{FullFilePath}"; } RelativeDropPath = relativeDropPath ?? Path.GetFileName(FullFilePath); if (fileContentInfo != null) { var contentInfo = fileContentInfo.Value; BlobIdentifier = ContentHashToBlobIdentifier(contentInfo.Hash); FileLength = contentInfo.HasKnownLength ? contentInfo.Length : UnknownFileLength; } else { BlobIdentifier = null; FileLength = UnknownFileLength; } }
private string RenameByDateTime(DateTime dateTime) { string destPath = Path.Combine(FullDirectoryPath, ComposeNameFromEpochTime(dateTime)); if (FullFilePath.Equals(destPath)) { // 文件名未改变 return(String.Empty); } if (File.Exists(destPath)) { return(String.Format("'{0}' 无法被重命名为 '{1}',因为目标已存在!", this.FullFilePath, destPath)); } File.Move(this.FullFilePath, destPath); return(String.Empty); }
public int CompareTo(FileBroker other) { int compare = 0; FullFilePath.CompareTo(other.FullFilePath); if (this.Broker > other.Broker) { compare = -1; } if (this.Broker < other.Broker) { compare = 1; } if (compare == 0) { compare = FullFilePath.CompareTo(other.FullFilePath); } return(compare); }