Getting Timeout Error while downloading file from Internet

PiyushKPiyushK USMember

I am trying to download a file on button click using the below code. It always give me a timeout error. Please provide any solution for it. Does iOS need any special code aor access to allow apps use Internet?

long iFileSize = 0;
int iBufferSize = 1024;
iBufferSize *= 1000;
long iExistLen = 0;
FileStream saveFileStream;
if (File.Exists(sDestinationPath))
FileInfo fINfo = new FileInfo(sDestinationPath);
iExistLen = fINfo.Length;
if (iExistLen > 0)
saveFileStream = new FileStream(sDestinationPath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
saveFileStream = new FileStream(sDestinationPath, FileMode.OpenOrCreate, FileAccess.ReadWrite);

        System.Net.HttpWebRequest hwRq;
        System.Net.HttpWebResponse hwRes;

        WebProxy proxy = new WebProxy();
        proxy.UseDefaultCredentials = true;

        hwRq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(sSourceURL);
        hwRq.Proxy = proxy;
        hwRq.Timeout = 200000;
        System.IO.Stream smRespStream;
        hwRes = (System.Net.HttpWebResponse)hwRq.GetResponse();
        smRespStream = hwRes.GetResponseStream();

        iFileSize = hwRes.ContentLength;

        int iByteSize;
        byte[] downBuffer = new byte[iBufferSize];

        while (((iByteSize = smRespStream.Read(downBuffer, 0, downBuffer.Length)) > 0) && !isPauseClicked)
            saveFileStream.Write(downBuffer, 0, iByteSize);

I am trying to save file in "Environment.GetFolderPath(Environment.SpecialFolder.Personal);". Is there any other way to store it in iPhone memory?

Sign In or Register to comment.