本文介绍了找不到文件异常(尽管文件存在)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生,我正在使用网络服务将图像保存在数据库中
网络服务代码
sir i am using webservice to save the images in database
webservice code
public void save_Image(int id, byte []ar)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText="insert into tbimage values(@id,@nam)";
cmd.Connection=con;
cmd.Parameters.Add("@id",SqlDbType.Int).Value=id;
cmd.Parameters.Add("@nam",SqlDbType.Image).Value=ar;
cmd.ExecuteNonQuery();
cmd.Dispose();
}
使用此Web服务的Webform
Webform which consumes this webservice
protected void Button1_Click(object sender, EventArgs e)
{
abc.WebService obj = new abc.WebService();
int ln = FileUpload1.PostedFile.ContentLength;
byte []arr=new byte[ln];
FileStream fs = new FileStream(FileUpload1.PostedFile.FileName,FileMode.Open,FileAccess.Read);
fs.Read(arr, 0, ln - 1);
fs.Close();
obj.save_rec(Convert.ToInt32(TextBox1.Text),arr);
TextBox1.Text = string.Empty;
TextBox1.Focus();
}
请帮助
please help
推荐答案
这篇关于找不到文件异常(尽管文件存在)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!