找不到文件异常(尽管文件存在) [英] File Not Found exception (though file exists)

查看:121
本文介绍了找不到文件异常(尽管文件存在)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我正在使用网络服务将图像保存在数据库中

网络服务代码

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

推荐答案

在下面的链接中尝试此操作

http://asp.net-tutorials.com/controls/file-upload-control/ [ ^ ]
Try this below link

http://asp.net-tutorials.com/controls/file-upload-control/[^]


使用完整链接

http://csharpdotnetfreak.blogspot.com/2009/07/fileupload-control- save-images-database.html [ ^ ]
use full link

http://csharpdotnetfreak.blogspot.com/2009/07/fileupload-control-save-images-database.html[^]


这篇关于找不到文件异常(尽管文件存在)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆