image.save 无法覆盖源文件,该如何操作?
谢谢
------解决方案--------------------------------------------------------
你可以试试这种方法
- C# code
Image ReducedImage;using( System.IO.Stream stream = System.IO.File.OpenRead(resourceFile)){ ReducedImage = Image.FromStream(stream); Image.GetThumbnailImageAbort callb = new Image.GetThumbnailImageAbort(ThumbnailCallback); if ((ResourceImage.Width / ResourceImage.Height) >= 1) { ImageWidth = maxSize; ImageHeight = (ResourceImage.Height) * ImageWidth / ResourceImage.Width;//等比例缩放 } else { ImageHeight = maxSize; ImageWidth = (ResourceImage.Width) * ImageHeight / ResourceImage.Height;//等比例缩放 } ReducedImage = ResourceImage.GetThumbnailImage(ImageWidth, ImageHeight, callb, IntPtr.Zero); ReducedImage.Save(targetFilePath, ImageFormat.Jpeg); ReducedImage.Dispose();} return true;