大文件的处理
大文件的处理
let rec transforAsync (streamIn:Stream) (streamOut:Stream) buffer = async{
let! lengthRead = streamIn.AsyncRead(buffer, 0, buffer.Length)
if (lengthRead >0) then
do! streamOut.AsyncWrite(buffer, 0, lengthRead)
do! transforAsync streamIn streamOut buffer
}
let postHttpCookieAsync (url : string) (postData :string) (cookie : CookieContainer byref)=
let data = Encoding.UTF8.GetBytes(postData)
let req = WebRequest.Create( url ) :?> HttpWebRequest
req.Timeout <- 6000000
req.CookieContainer <- cookie
req.Method <- "POST" www.zzzyk.com
req.ContentType <- "application/x-www-form-urlencoded"
req.AllowAutoRedirect <- true
req.KeepAlive <- true
req.ServicePoint.ConnectionLimit <- 10
use ss = req.GetRequestStream()
ss.Write(data,0,data.Length)
async{
let! resp = req.AsyncGetResponse()
use streamIn = resp.GetResponseStream()
use streamOut = File.Create(t1, 1024*100, FileOptions.Asynchronous)
let buffer = Array.zeroCreate(1024*10)
do! transforAsync streamIn streamOut buffer
}
补充:综合编程 , 其他综合 ,