Re: Dowload File




John Timney (MVP) wrote:
Well if its not your server theres probably not much you can do then other
than to try and work out how long a file may take to be created based on
your testing and compensate accordingly.

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com


"rony_16" <rony.vainblat@xxxxxxxxx> wrote in message
news:1158733147.299398.203230@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thye problem is that nothing is returned to me , i just give the order
to prepar the file.
i don't a way of cheking if the file is ready.

this page that i am requesting is not may page, is someone else page.

John Timney (MVP) wrote:
Thats your page just saying its succesfully completed - that doesn't mean
the server has completed writing your file asd you have found. Try what
I
suggested - go to another page and check if the file has finished writing
from that page.

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com


"rony_16" <rony.vainblat@xxxxxxxxx> wrote in message
news:1158678791.844282.274770@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I tried to check the status
for example :
while (myresponse.StatusCode!=HttpStatusCode.Ok)
{
Thread.Sleep(500);
}

but the StatusCode always HttpStatusCode.NoContact
and never changes.




John Timney (MVP) wrote:
You will need to work out a way of indicating the the file has
completed
process. Perhaps a second page that you can poll to check status
before
you
download the file allowing your job to complete before you actually
try
to
download. A succesful attempt toopen the file for exclusive use would
be
enough to say if the file had finished being written so you could
download
it.

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com


"rony_16" <rony.vainblat@xxxxxxxxx> wrote in message
news:1158674428.750243.83030@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I have problem with downloading a file using WebRequest and
HttpWebResponse.
Inorder to download this file i need to call to url that tells to
prepare the file for download,
and then i call to another url that downloads the file.
I have a problem with that because:

1. i do not know when the server finished the preparetion.
2.i checked the HttpStatusCode but he doen't changes
(myresponse.StatusCode).

the problem causes the application to download only a part of the
file
and that because the server hasn't prepared the file yet.
if i give him Thread.Sleep(100000) i do get the full file, but the
file
can be 100Mb and 10sec won't help.

the code is:
//Preparing the file todownload...
//---------------------------------------------------------------------------------------------------------
HttpWebRequest webRequest3 = WebRequest.Create(d1) as
HttpWebRequest;
webRequest3.KeepAlive = true;
webRequest3.Headers.Add("Keep-Alive", "300");
webRequest3.Headers.Add("Accept","text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
webRequest3.Headers.Add("Accept-Language",
"en-us,en;q=0.5");
webRequest3.Headers.Add("Accept-Encoding",
"gzip,deflate");
webRequest3.Headers.Add("Accept-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7");

webRequest3.CookieContainer = cookies;
HttpWebResponse myResponse3 =
(HttpWebResponse)webRequest3.GetResponse();

Thread.Sleep(10000);
Stream ReceiveStream3 = myResponse3.GetResponseStream();

//-----------------------------------------------------------------------------------

//Downloading ....
//--------------------------------------------------------------------------------------
Console.WriteLine("Connecting to download link...");
HttpWebRequest webRequest2 = WebRequest.Create(re) as
HttpWebRequest;
webRequest2.ContentType =
"application/x-www-form-urlencoded";
webRequest2.KeepAlive = true;
webRequest2.CookieContainer = cookies;
HttpWebResponse myResponse2 =
(HttpWebResponse)webRequest2.GetResponse();
Stream ReceiveStream2 = myResponse2.GetResponseStream();
Console.WriteLine("Downloading...");

Common.SaveStreamToFile(@"C:\scrapingtest\file.csv",
ReceiveStream2);
Console.WriteLine("Done Downloading");

Thanks, Rony



I did it....
and it works.


HttpWebRequest webRequest3 = WebRequest.Create(d1) as HttpWebRequest;
webRequest3.KeepAlive = true;
webRequest3.Headers.Add("Keep-Alive", "300");
webRequest3.Headers.Add("Accept-Language",
"en-us,en;q=0.5");
webRequest3.Headers.Add("Accept-Encoding", "gzip,deflate");
webRequest3.Headers.Add("Accept-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7");
webRequest3.CookieContainer = cookies;
HttpWebResponse myResponse3 =
(HttpWebResponse)webRequest3.GetResponse();
while (myResponse3.StatusCode != HttpStatusCode.OK)
{
webRequest3 = WebRequest.Create(d1) as HttpWebRequest;
webRequest3.KeepAlive = true;
webRequest3.Headers.Add("Keep-Alive", "300");
webRequest3.Headers.Add("Accept-Language",
"en-us,en;q=0.5");
webRequest3.Headers.Add("Accept-Encoding",
"gzip,deflate");
webRequest3.Headers.Add("Accept-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7");
webRequest3.CookieContainer = cookies;
myResponse3 =
(HttpWebResponse)webRequest3.GetResponse();
}

Thanks,Rony

.



Relevant Pages

  • Re: MSDN Subscribers: Did you get your DVD for VS 2005?
    ... John Timney ... ASP.NET MVP ... >some morons supporting MSDN which was a support experience I'd rather try ... I had to download it from the website. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Need Script to Download Files from Webserver
    ... Theres lots of ... John Timney (MVP) ... and then download them to their harddrive. ...
    (microsoft.public.dotnet.general)
  • Re: Dowload File
    ... John Timney (MVP) wrote: ... download the file allowing your job to complete before you actually try to ... HttpWebResponse. ...
    (microsoft.public.dotnet.general)
  • Re: Office 2003 SP2
    ... Then what you have seen from other MVPs and Microsoft employees post is ... The only redistribution CD for an SP I have even ... Milly Staples [MVP - Outlook] ... | If you post it on a web site for download, ...
    (microsoft.public.officeupdate)
  • Re: Office 2003 SP2
    ... If you post it on a web site for download, ... Microsoft MVP - FrontPage ... I would like to inform you that Office 2003 Service pack 2 update is ... installing the CD of the downloaded and redistributed patch to get ...
    (microsoft.public.officeupdate)

Loading