如何将图像保存到运行时创建的文件夹中 [英] how to save the images to a folder created at run time
本文介绍了如何将图像保存到运行时创建的文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已从sql中检索图像并显示在网页中。
同时我在运行时使用
创建了名为images的文件夹
Directory.CreateDirectory(NewDirectory);
已创建文件夹,现在我想将从sql检索到的所有图像移动或保存到此文件夹....如何做到....
I have retrieved the images from sql and displayed in the web page.
At the same time i created folder named images at runtime by using
Directory.CreateDirectory(NewDirectory);
Folder has been created, now i want to move or save all the images retrieved from sql to this folder.... how to do that....
推荐答案
参考
如何将图像从sql数据库保存到文件夹中 [ ^ ]
你为什么要那样做?您可以使用将图像传递给客户端的代码中的File.WriteAllBytes来执行此操作
Why would you want to do that ? You can do it with File.WriteAllBytes in the code that passes the image to the client
尝试如下: -
try like this:-
System.Drawing.Bitmap bmp; // your image object
bmp.Save(Server.MapPath("~" + "/" + "Image.png"));
或
or
System.Drawing.Image img; // your image object
img.Save((Server.MapPath("~" + "/" + "Image.png"));
在上面的代码中添加crated文件目录路径。
add you crated file directory path in above code.
这篇关于如何将图像保存到运行时创建的文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文