c#通过http流到iphone我正在尝试通过http将视频流到iphone,而无需使用.net的流服务器。经过一些测试,我发现如果你只是将iphone兼容的视频上传到你的服务器,iis7工作正常,iphone在一个小的缓冲时间后开始播放视频并继续在后台下载。我的问题是,我无法使用.net执行此操作。我试过publicstaticvoidSmallFile(stringfilename,stringfilepath,stringcontentType){try{FileStreamMyFileStream=newFileStream(filepath,FileMode.Open,FileAccess.Read,FileShare.Read);长文件大小;FileSize=MyFileStream.Length;byte[]Buffer=newbyte[(int)FileSize];MyFileStream.Read(Buffer,0,(int)MyFileStream.Length);我的文件流.Close();HttpContext.Current.Response.ContentType=contentType;HttpContext.Current.Response.AddHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(filename,System.Text.Encoding.UTF8));HttpContext.Current.Response.BinaryWrite(缓冲区);}catch{HttpContext.Current.Response.ContentType="text/html";HttpContext.Current.Response.Write("下载错误!"+文件名+"未找到!");}HttpContext.Current.Response.End();}或者publicstaticvoidResumableFile(stringfilename,stringfullpath,stringcontentType){try{FileStreammyFile=newFileStream(fullpath,FileMode.Open,FileAccess.Read,FileShare.ReadWrite);BinaryReaderbr=newBinaryReader(myFile);尝试{HttpContext.Current.Response.AddHeader("Accept-Ranges","bytes");HttpContext.Current.Response.Buffer=false;长文件长度=myFile.Length;长起始字节=0;//intpack=10240;//10K字节intpack=1048576;//1024K字节if(HttpContext.Current.Request.Headers["Range"]!=null){HttpContext.Current.Response.StatusCode=206;string[]range=HttpContext.Current.Request.Headers["Range"].Split(newchar[]{'=','-'});startBytes=Convert.ToInt64(范围[1]);}HttpContext.Current.Response.AddHeader("Content-Length",(fileLength-startBytes).ToString());if(startBytes!=0){HttpContext.Current.Response.AddHeader("Content-Range",string.Format("bytes{0}-{1}/{2}",startBytes,fileLength-1,fileLength));}HttpContext.Current.Response.AddHeader("Connection","Keep-Alive");HttpContext.Current.Response.ContentType=contentType;HttpContext.Current.Response.AddHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(filename,System.Text.Encoding.UTF8));br.BaseStream.Seek(startBytes,SeekOrigin.Begin);intmaxCount=(int)Math.Floor((double)((fileLength-startBytes)/pack))+1;对于(inti=0;i
