public static void RenameFile(string folderPath, string name, string newname) { string oldFile = Path.Combine(folderPath, name); string newFile = Path.Combine(folderPath, newname); string oldExtensionFile = OSFileInfo.GetExtensionFilePath(oldFile); string newExtensionFile = OSFileInfo.GetExtensionFilePath(newFile); string oldThumbnailPath = AttachmentManager.GetThumbnailPath(oldFile, "thumbnail", "png"); string newThumbnailPath = AttachmentManager.GetThumbnailPath(newFile, "thumbnail", "png"); if (System.IO.File.Exists(newFile)) { throw new Exception(String.Format(Resources.YZStrings.Aspx_FileSystem_Ext_FileWithSameNameAleardyExist, newname)); } System.IO.File.Move(oldFile, newFile); if (System.IO.File.Exists(oldExtensionFile)) { System.IO.File.Delete(newExtensionFile); System.IO.File.Move(oldExtensionFile, newExtensionFile); } if (System.IO.File.Exists(oldThumbnailPath)) { System.IO.File.Delete(newThumbnailPath); System.IO.File.Move(oldThumbnailPath, newThumbnailPath); } }
public OSFileInfo(FileInfo fileInfo) : this() { this.FileInfo = fileInfo; OSFileInfo extInfo = this.TryLoadExtensionInfo(this.ExtensionFilePath); if (extInfo != null) { this.Copy(extInfo); } }
public static void MoveFiles(string folderPath, BPMObjectNameCollection excludes, string[] filenames, string targetfilename, MovePosition position) { OSFileInfoCollection fileInfos = GetFiles(folderPath, excludes); fileInfos.Move <string>("Name", filenames, targetfilename, position); for (int i = 0; i < fileInfos.Count; i++) { OSFileInfo fileInfo = fileInfos[i]; fileInfo.OrderIndex = i; fileInfo.SaveExtensionInfo(); } }
public static void DeleteFile(string folderPath, string name) { string file = Path.Combine(folderPath, name); string extensionFile = OSFileInfo.GetExtensionFilePath(file); string thumbnailPath = AttachmentManager.GetThumbnailPath(file, "thumbnail", "png"); System.IO.File.Delete(file); if (System.IO.File.Exists(extensionFile)) { System.IO.File.Delete(extensionFile); } if (System.IO.File.Exists(thumbnailPath)) { System.IO.File.Delete(thumbnailPath); } }
int IComparable.CompareTo(object obj) { OSFileInfo other = obj as OSFileInfo; if (other == null) { return(-1); } if (this.OrderIndex != other.OrderIndex) { return(this.OrderIndex - other.OrderIndex); } else { return(String.Compare(this.Name, other.Name)); } }
public void Copy(OSFileInfo extInfo) { this.OrderIndex = extInfo.OrderIndex; }