易截截图软件、单文件、免安装、纯绿色、仅160KB

将图片等文件保存到sqlite中(c#)

 SqLite.net的dll为System.Data.SQLite.dll,这种dll分为32位、64位和适用于compactframework三种,在引用时要注意,选择正确的dll。
将要保存图片的字段类型设为blob。代码如下:
private void savePicture()
{
using (SQLiteConnection cnn = new SQLiteConnection(dbPath))
{
cnn.Open();
using (SQLiteCommand cmd = cnn.CreateCommand())
{
//cmd.CommandText = "Create Table test(data Image)";
//cmd.ExecuteNonQuery();
cmd.CommandText = "insert into person values('12',@data,'14','13')";
SQLiteParameter para = new SQLiteParameter("@data", DbType.Binary);
string file = @"F:\Image\飞机.png";
FileStream fs = new FileStream(file, FileMode.Open);
//StreamUtil su = new StreamUtil();
//byte[] buffer = su.StreamToBytes(fs);
byte[] buffer = StreamUtil.ReadFully(fs);
fs.Close();
para.Value = buffer;
cmd.Parameters.Add(para);
cmd.ExecuteNonQuery();
}
}
}

其中StreamUtil为自定义的一个类:
public static class StreamUtil
{
const int BufferSize = 8192;
public static void CopyTo(Stream input,Stream output)
{
byte[] buffer = new byte[BufferSize];

int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}

public static byte[] ReadFully(Stream input)
{
using (MemoryStream tempStream = new MemoryStream())
{
CopyTo(input, tempStream);
return tempStream.ToArray();
}
}

}

参考:http://www.


相关文档:

C#操作xml

引用命名空间:using System.Xml 
1.检查所要操作的xml文件是否存在:
   System.IO.File.Exists(文件路径及名称);
2.得到xml文件:
(1)在asp.net中可以这样得到:
XmlDocument xmlDoc = new XmlDocument();
//导入xml文档
xmlDoc.Load( Server.MapPath("xmlTesting.xml"));
//导入字符串
/ ......

JavaScript与C#之间函数与变量的相互调用(转)

问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
 
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中;
  &n ......

搜索之路 c#从html中提取文本

直接封装成一个类的,用起来还挺方便的
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text ......

asp.net c# js服务器端常用

using System;
using System.Web;
namespace pub.mo
{
public class js
{
private js() { }
private static string scr_j1 = "<mce:script type=\"text/javascript\"><!--
";
private static string scr_j2 = "
// --></mce:script>";
/// <summa ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号