0

我正在尝试设计一个简单的脚本来下载文件......但我被卡住了......

到目前为止我做了什么:

    request = WebRequest.Create(page)       
    request.Credentials = NetworkCredential("name", "pw")
    request.CookieContainer = CookieContainer
    request.Method = WebRequestMethods.Http.Get     
    request.ContentType = "application/octet-stream"        
    response = request.GetResponse()
    length = response.ContentLength

    writeStream = System.IO.FileStream(fi, System.IO.FileMode.Create)           
    Bytes = Array.CreateInstance(int,8192)

    bytesread = response.GetResponseStream()                        
    #encode = System.Text.Encoding.GetEncoding("utf-8");
    readStream = System.IO.StreamReader(bytesread)
    count = readStream.Read(Bytes, 0, 8192)         

    while True:                         
        count = readStream.Read(Bytes, 0, 8192)         
        if count == 0:break
        writeStream.Write(Bytes, 0, bytesread)

    response.Close()
    writeStream.Close()
    response = request.GetResponse()

“fi”是我磁盘上的文件名,“page”是指向网络上 z 文件的 uURl。

错误在 CreateInstance 中,要求使用 Char 数组而不是 int ......但是,我怎样才能创建一个字符数组???

谢谢...

4

1 回答 1

1

你有没有尝试过:

bytes = Array[Char](range(8192))
于 2012-01-03T10:33:01.293 回答