C# 复制图像并将其保存到其他目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13012864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 01:20:51  来源:igfitidea点击:

copy an image and save it to other directory

c#winforms

提问by Mr_Green

I am beginner in c#. In my project, if I do try the below code to save a copy of image, it is giving error "A generic error occurred in GDI+." . I have gone through this link, but I have no knowledge of what is he saying.

我是 C# 的初学者。在我的项目中,如果我确实尝试使用以下代码来保存图像副本,则会出现错误“GDI+ 中发生一般错误”。. 我已经浏览了这个链接,但我不知道他在说什么。

I tried the below code:

我尝试了以下代码:

 Bitmap bmpLarge = new Bitmap(ofdFlagsLarge.FileName);
 bmpLarge.Save(@"\..\..\" + strLargePath);               /* ERROR */

Can someone please assist me to save a image from the local PC directory itself to other directory on the same machine..

有人可以帮我将本地 PC 目录本身的图像保存到同一台机器上的其他目录吗?

采纳答案by middelpat

You just want to copy a file?

你只是想复制一个文件?

Why not use:

为什么不使用:

System.IO.File.Copy("source", "destination");

http://msdn.microsoft.com/en-us/library/c6cfw35a.aspx

http://msdn.microsoft.com/en-us/library/c6cfw35a.aspx