Download File - Ironpython
-
12-04-2021 - |
Question
I am trying to design a simple script to download a file... but i'm stuck...
Wht i did until now:
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" is filename on my disk, "page" an uURl pointing to z file on the web.
The error is in the CreateInstance, asking for Char array instead of int... but, how can i create an array of chars???
Thanks...
Solution
Have you tried:
bytes = Array[Char](range(8192))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow