我选择要做的接收图片的aspx页面。要求是别人通过url访问我的页面,给我传的二进制数组(Byte)还有图片的名称,传过来的数组是这张图片的一部分,也就是他把图片分成N多个的数组访问N多次我的页面,我根据他传过来的图片名称来判断,如果已经存在就要在存在的那张图片上继续追加。。不存在则新建有知道怎么写的吗?我写的图片有的不显示有的显示半截。。
我的代码if (File.Exists(fullpath))
                    {
                        //读取
                        fs = new FileStream(fullpath, FileMode.Open);
                        //fs = new FileStream(fullpath, System.IO.FileAccess.ReadWrite);
                        int iLength = int.Parse(fs.Length.ToString());//获取当前文件的长度
                        Byte[] fileByte = new Byte[iLength];//创建一个byte[]的数组,用来保存文件的内容
                        fs.Read(fileByte, 0, iLength);//通过Read方法,把文件的内容读取到byte[]数组中。
                        fs.Close();
                        int length = fileByte.Length + fileContent.Length;
                        Byte[] newByte = new Byte[length];
                        fileByte.CopyTo(newByte, 0);
                        fileContent.CopyTo(newByte, fileByte.Length - 1);
                        //写入
                        sw = new FileStream(fullpath, System.IO.FileMode.Create,   System.IO.FileAccess.ReadWrite, System.IO.FileShare.None, 4096, false);
                        sw.Write(newByte, 0, newByte.Length);
                        sw.Close();
                    }
比方说第一次传的数组写为图片后无法显示,下次读这张图片时数组的值会全是0
高手们指点指点了

解决方案 »

  1.   

    上面是如果存在这张图片的代码,这是不存在时的代码
    else
                        {                        sw = new FileStream(fullpath, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.None, 4096, false);
                            sw.Write(fileContent, 0, fileContent.Length);
                            sw.Close();                    }
    看到的人帮帮忙了
      

  2.   

    为什么要那么复杂的 <input type=file>就可以了
      

  3.   

    不行的我写的这个是他们要调用的他们写的是手机操作的一个东西这个图片是他们传给我,要我保存下来的,我有想过存到数据库,可是数据库的image类型好像跟上面stream写图片有一样的问题。
      

  4.   

    up     up            up