我选择要做的接收图片的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
高手们指点指点了
我的代码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
高手们指点指点了
解决方案 »
- 中小企业的网站吗?一般是用什么软件来做?有没有什么现成的系统能快速生成一个简单的企业网站,有点企业介绍,产品展示,联系我们之类的栏目就行。
- 数据添加到sql数据库 怎么读取进度
- 请问一下同程网这种静态页面如何实现?
- 如何让html页生成图片
- 还是远程数据库连接问题,无法解决
- 这条语句为什么出现错误?
- 请教一个关于LISTBOX的问题,百分相赠!高手请指教!
- HttpWebRequest与WebRequest的区别是什么?
- HTTP/1.1 503 Service Unavailable急
- 为什么我刚刚新建的ASP.NET项目就无法运行??错误提示见正文
- 前台如何用jquery获取FCKeditor 的值
- asp.net 收邮件
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(); }
看到的人帮帮忙了