知道的大哥们能不能给我一段实现上传的代码参考一下,我是用ADO.NET连接ODBC数据源,最好是informix数据库的,我用的字段是BYTE。

解决方案 »

  1.   

    以下是我的另一个问题,欢迎大家踊跃接分,不胜感谢!
    http://community.csdn.net/Expert/topic/4277/4277503.xml?temp=6.757754E-02
      

  2.   

    可以分为两端,
    1.上传文件到服务器(包括相关的检验动作)
    2.将上传上来的文件流保存到数据库中(应该使用带参数的SQL保存形式)有个建议,一般是不将文件流保存到数据库中(像SPS这类的文件管理的都没有这样做)
    那样会使数据库变得很大,而且效率很低,一般是DB中保存一个文件的路径就OK。
      

  3.   

    njbaige(白鸽) 大哥,能不能给一段参考的代码,思路倒是简单,但问题是怎么实现。
      

  4.   

    最好通过FTP把文件传输到服务器上,然后手动添加包含文件路径的纪录到数据库中
    用http传送大的文件不是很好
      

  5.   

    现在的问题是我们经理要求把某些文档直接存在informix数据库中,通过FTP传到服务器上的方法倒是已经实现了。
    用ADO方式存取的话有个appendChunk函数,但是用ADO.NET方式就没有这个函数了,好像是要用FileStream的方式,但是本人太菜,不知道用这个方式怎么实现把各种文档存到数据库中。
      

  6.   

    我执行这段代码花费了10几分钟的时间。(复制儿魂.rmvb的大小为309M)try 

    string Path = "E:\\adobmcom\\test1.rmvb";
    Stream st = client.OpenRead("D:\\Program Files\\BitComet\\Downloads\\www.167bt.com@复制儿魂\\复制儿魂.rmvb"); 
    StreamReader reader = new StreamReader(st); 
    byte[] mbyte = new byte[400000000]; 
    int allmybyte = (int)mbyte.Length; 
    int startmbyte = 0; 

    while(allmybyte>0) 

    int m = st.Read(mbyte,startmbyte,allmybyte); 
    if(m==0) 
    break;  startmbyte+=m; 
    allmybyte-=m; 
    }  FileStream fstr = new FileStream(Path,FileMode.OpenOrCreate,FileAccess.Write); 
    fstr.Write(mbyte,0,startmbyte); 
    st.Close(); 
    fstr.Close();  
    }
      

  7.   

    zhun_yi(cpic)
    那你的数据库还不要暴掉!呵呵 !
    oracle 字段要设置为BLOB
    //将文件转化成字节数组,保存到数据库
    private byte[] GetFileBytes(string Filename)
    {
    if(Filename=="") return null;
    FileStream fileStream = new FileStrea(Filename,FileMode.Open, FileAccess.Read);
    BinaryReader binaryReader = new BinaryReader(fileStream);

    byte[] fileBytes = binaryReader.ReadBytes((int)fileStream.Length);
    binaryReader.Close();
    fileStream.Close();
    return fileBytes;
    }
    在打开的时候呢 要注意文件的后缀名
    FileInfo fileInfo = new FileInfo(fileName )
    Process.Start(fileName + fileInfo.Extension)
    这样你读就没有问题了
      

  8.   

    谢谢各位,特别谢谢xjaifly(tiantian)兄弟,结帖。