❶ c#怎样从数据库读取图片并保存到指定文件
SqlDataAdapter da = new SqlDataAdapter("select * from newpicture", conn);
DataSet ds = new DataSet();
da.Fill(ds, "pic");
string picdotname;
string picfilename;
int piclength;
int i;
//添加新列
DataColumn newcolumn = ds.Tables["pic"].Columns.Add("pic_url", typeof(string));
for (i = 0; i < Convert.ToInt16(ds.Tables["pic"].Rows.Count); i++)
{
picdotname = ds.Tables["pic"].Rows[i]["pic_dot"].ToString();
piclength = Convert.ToInt32(ds.Tables["pic"].Rows[i]["pic_length"]);
picfilename = Server.MapPath("temp/") + "temp" + i.ToString() + "." + picdotname;
FileStream fs = new FileStream(picfilename, FileMode.Create, FileAccess.Write);
byte[] piccontent = new byte[piclength];
piccontent = (byte[])ds.Tables["pic"].Rows[i]["pic_content"];
fs.Write(piccontent, 0, piclength);
fs.Close();
ds.Tables["pic"].Rows[i]["pic_url"] = "temp/temp" + i.ToString() + "." + picdotname;//相对路径,改成你自己的文件夹
}
数据源 = ds.Tables["pic"];//数据绑定
大体是这样吧,里面表名列名很多细节你按你的表修改吧!
用哪个控件都行,只要图片路径正确就能显示的
❷ 怎样用c#将picturebox中的图片保存到指定文件夹中,是纯c#不是.net
1.C#与.NET是不同的概念,.NET是微软提供的托管代码的公共框架,C#是运行于其上的一种高级语言。
2.保存图片代码
//取得PictureBox中的图片对象
Image imgSave = picturebox1.Image;
//保存到本地,路径可自行设置
imgSave.Save("D:\\Image\\mypic.jpg");
❸ 易语言怎么把图片框的图片保存到指定文件夹
解决这个问题的方法如下:
1、首先打开易语言软件。
❹ vb中如何保存一张图片在指定文件夹里
'定义一个目录及文件名变量
dim curDire as string
dim curFile as string
'赋值
curDire=App.Path+"\1" '当前系统目录下的 ...\1子目录
curFile=curDire + "\f1234.bmp" '文件名为 f1234.bmp 图片文件
'判断子目录是否存在,不存在则创建
If Len(Dir$(curDire,vbDirectory)) = 0 Then MkDir curDire
'判断文件是否存在,如存在就删除该文件
if Len(Dir$(curFile))>0 Then Kill curFile
'将Picture1 中的图片文件保存
SavePicture Picture1.Image, curFile
❺ PS处理好图片后怎么快速保存图片到指定的文件夹比如按一下就保存了
分2种情况:
1、用修改后的图片直接替换原图,快捷键“ctry+s”即可保存到原图所在的文件夹,并替换原图
2、把修改后的图片副本保存到指定文件夹,快捷键“Ctrl+Shift+S ”,弹出另存窗口,选择指定的文件夹保存。
另,也可以自己利用“动作”设置快捷键,实现相应操作,并存储。
❻ 在C#(c/s)中如何实现将打开的图片保存到指定的文件夹中
public static int SaveImageFromWeb(string imgUrl,string path,string fileName)
...{
if(path.Equals(\"\"))
throw new Exception(\"未指定保存文件的路径\");
string imgName = imgUrl.ToString().Substring(imgUrl.ToString().LastIndexOf(\"/\")+1);
string defaultType = \".jpg\";
string[] imgTypes = new string[]...{\".jpg\",\".jpeg\",\".png\",\".gif\",\".bmp\"};
string imgType = imgUrl.ToString().Substring(imgUrl.ToString().LastIndexOf(\".\"));
foreach (string it in imgTypes)
...{
if (imgType.ToLower().Equals(it))
break;
if (it.Equals(\".bmp\"))
imgType = defaultType;
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(imgUrl);
request.UserAgent = \"Mozilla/6.0 (MSIE 6.0; Windows NT 5.1; Natas.Robot)\";
request.Timeout = 3000;
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
if( response.ContentType.ToLower().StartsWith(\"image/\") )
...{
byte[] arrayByte = new byte[1024];
int imgLong = (int)response.ContentLength;
int l = 0;
if(fileName == \"\")
fileName = imgName;
FileStream fso = new FileStream(path+fileName+imgType,FileMode.Create);
while(l<imgLong)
...{
int i = stream.Read(arrayByte,0,1024);
fso.Write(arrayByte,0,i);
l += i;
}
fso.Close();
stream.Close();
response.Close();
return 1;
}
else
...{
return 0;
}
}
❼ JS中如何把上传的图片保存到指定文件目录
用JSPSMART处理,参考下面代码实现
<%
//程序初始化 下面设置成要保存的文件夹
String path_tmp = request.getRealPath("/") + "Upload";
String filename_p = "Test";
String path_new = request.getRealPath("/") + "Upload\\" + filename_p;
//文件上传
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.upload();
int count = su.save(path_tmp);
//参数提取,后面贴不了,说我的重复内容多,这玩意真差...
%>
❽ 在java 中在代码中要引用的图片该放在哪个文件
放到任意文件夹都可以,看你的管理方式。
1、放到和程序目录下的某个文件夹中。
//假设图片放到程序运行目录的img目录下
BufferedImageimg=ImageIO.read(newFile("img/my.png"));
2、放到源文件中,和读取类在同一目录,使用时图片要按包名打包到jar中
//假设图片放到src下,和MyImages在一个目录
BufferedImageimg=ImageIO.read(MyImages.class.getResource("my.png"));
3、放到源文件中,但在独立文件夹中,使用时图片要按包名打包到jar中
//假设图片放到src下的img目录中
BufferedImageimg=ImageIO.read(MyImages.class.getResource("res/my.png"));
❾ js中如何将某地址的图片保存到本地指定文件夹中
用JSPSMART处理,参考下面代码实现:
<%
//程序初始化 下面设置成要保存的文件夹。
String path_tmp = request.getRealPath("/") + "Upload";
String filename_p = "Test";
String path_new = request.getRealPath("/") + "Upload\" + filename_p;
//文件上传。