Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }