将图像从文件夹保存到另一个名称不同的文件夹

时间:2022-01-06 00:23:59

I have an image name defaultImage.jpeg. I can get the image using the following code:

我有一个图像名称defaultImage.jpeg。我可以使用以下代码获取图像:

string defaultImageDir = AppDomain.CurrentDomain.BaseDirectory + "\\Images\\defaultImage.jpeg";

Say that I create a dog, a Mastiff for some reason. While the app creates the dog, I would like to get this default image, then save it in a particular folder under the name of the dog. But I've never worked with images else the one we load from the net and this one is already in the project, so how might I do this?

说我出于某种原因创造了一只狗,一只獒犬。当应用程序创建狗时,我想获取此默认图像,然后将其保存在狗名称下的特定文件夹中。但是我从来没有使用过我们从网上加载的那个图像,这个已经在项目中,所以我该怎么做呢?

1 个解决方案

#1


1  

You can copy the image from one directory to another.

您可以将图像从一个目录复制到另一个目录。

System.IO.File.Copy(Server.MapPath("/Images/defaultImage.jpeg"), Server.MapPath("/Dog/defaultImage.jpeg"));

While the first parameter is your source file and the second parameter is your destination file.

第一个参数是源文件,第二个参数是目标文件。

#1


1  

You can copy the image from one directory to another.

您可以将图像从一个目录复制到另一个目录。

System.IO.File.Copy(Server.MapPath("/Images/defaultImage.jpeg"), Server.MapPath("/Dog/defaultImage.jpeg"));

While the first parameter is your source file and the second parameter is your destination file.

第一个参数是源文件,第二个参数是目标文件。