求助用wcf做了个文件分段上传,怎么大文件,文件大小始终不对
代码如下
wcf端
public void BeginUpload(string FullPath, byte[] FileContext)
{
using (FileStream fs = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath(FullPath), FileMode.Append, FileAccess.Write))
{
fs.Write(FileContext, 0, FileContext.Length);
fs.Close();
fs.Dispose();
}
}
客户端
do
{
long len = fileLength- i1 * uploadIterations;
if (len < uploadIterations)
uploadIterations = int.Parse(len.ToString());
if (uploadIterations <= 0)
break;
byte[] buffer = new byte[uploadIterations];
read = fileStream.Read(buffer, 0, uploadIterations);
dc.BeginUpload(fileName, buffer);
i1++;
} while (read >= uploadIterations);
uploadIterations设置的为100k 2m以内的文件都能正常上传,2m以上的文件大小就不对了,md5也不对,文件也无法正常打开。