Dowload File

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

0
9/19/2006 1:59:50 PM
dotnet.xml 7266 articles. 0 followers. Follow

0 Replies
431 Views

Similar Articles

[PageSpeed] 0

Reply:

Similar Artilces:

number of fields exceeds 256 when importing from a dbf file
Hey evryone, I'm having a small problem with importing some old data from a FileMaker Pro database. According to what I found out in the groups archive the best bet is to convert it to a dbf file and then import it. However, I the number of fields in the dbf file exceeds 256, so the import wizard truncates the import at field number 256. I would now want to spread the data over two sheets. However, in the process of converting it to a dbf, quite a few of the field names get truncated and therefore have the same name, so I can't use SQL to retrieve them. My question is: what i...

File Error
When I send a simple file to a friend, they get a dialog box with the following information: "File Error. Some number formats may have been lost." The file seems to be ok on their end. Anyone know what this error is? Thanks, Bernie -- Regards; Rob ------------------------------------------------------------------------ "bw" <iamnu@cableone.net> wrote in message news:1105_1073581370@news.cableone.net... > When I send a simple file to a friend, they get a dialog box with the following information: > "File Error. Some number formats may have been lo...

Why excel close all files when I just want to close one files
Dear all, I opened several excel files, and now I want to close one file of the opened file. But when I close one file, all other files are closed and the whole excel is close. Is there any setting that I need to change in excel setting? Thanks There is no setting, but you have to be careful about what X you click on. If you click on the X at the top (the application window), then you're closing the application--not just the single workbook. Yes, excel behaves differently from MSWord. hon123456 wrote: > > Dear all, > > I opened several excel files, and n...

import ofx file in excel
How easy is it to import/view a money ofx file in excel without having money installed? (The ofx file is export from a banking program) How do you do this? I googled it but most stuff out there is either linking money with excel (means you need money program) or moving an excel file into money? Cannot find an easy solution, shoudl be becasue if you look at the file, it is like XML) Thx Philip Re: How easy is it to import/view a money ofx file in excel without having money installed? Reply: Very easy.. One way to accomplish this.... Open the saved bank ofx file with Notepad, on it&...

Personal File not closed properly
Help! Just started using Office 2007, and every time I open Outlook, I get the message 'A personal file was not closed properly. Please wait while Office/Outlook (can't remembers which) checks the file for errors.' As it happens, the checking doesn't take that long, but it is very annoying to get the message *every* time I start the darn thing. And I mean every, not just after it has frozen or crashed or something. Any ideas for getting it fixed would be gratefully received. Thanks Gareth See http://www.msoutlook.info/question/128 -- Robert Sparnaaij [MVP-Outlook] Co...

Pasword protected Excel file encrypted, how do I read this file?
I password protected an important file. My husband downloaded the Office 2003 upgrade last night. Now when I try to access the file I get this message...This is an Excel file, I don't know why it looks encrypted or why I can't access it. This file is not in a recognizable format. If you know the file is from another program which is incompatible with Microsoft Office Excel, click Cancel, then open this file in its orginal application. If you want to open the file later in Microsoft office Excel, save it in a format that is compatible, such as text format. If you suspect the...

Excel File Portection/Password
I have an excel document created in excel 02. I now need to open the doc in excel 2000. It is pwd protected but it won't open in excel 2000. Is there a work around? Hi Drew the file should open in Excel 2000 without a problem (after entering the password of course). What kind of error do you get? -- Regards Frank Kabel Frankfurt, Germany Drew wrote: > I have an excel document created in excel 02. I now need > to open the doc in excel 2000. It is pwd protected but it > won't open in excel 2000. Is there a work around? Hi Frank, It says the password is wrong. Thi...

Could not cleanup worktable IAM chains to allow shrink or remove file operation. Please try again when tempdb is idle
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01CB1448.E88B1160 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I'm getting this message when trying to clear tempdb DBCC SHRINKDATABASE (tempdb, 10) WITH NO_INFOMSGS=20 Msg 5054, Level 16, State 1, Line 1 Could not cleanup worktable IAM chains to allow shrink or remove file = operation. Please try again when tempdb is idle. Msg 5054, Level 16, State 1, Line 1 Could not cleanup worktable IAM chains to allow shrink or remove file = op...

How can I migrate all .n2k files from old terminal servers to new terminal servers?
I manage a Citrix Presentation Server 4.0 farm of about 30 servers. These servers are virtualized using ESX 3.5i and are running Windows Server 2003 SP2 as the OS. Ten are these servers are currently being used as published desktops. These desktop servers are then used as a regular working desktop by Domain Users after they login thru a Web Interface. These desktop servers currently have Office 2003 Pro installed locally. End users are then able to use the Office apps once they login to the published desktops. I recently tried upgrading from Office 2003 to 2007 on a couple of these ten d...

Help File Will Not Launch
Clicking on the online user guide link for Money 2004 found at http://www.microsoft.com/money/support/manual/ produces no results. It behaves like a dead link, but I'm sure thousands of people would have notified Microsoft if it were. Any idea what settings I should check on my machine? -or- Can the user guide be downloaded to a user's machine and then opened? In microsoft.public.money, Ross wrote: >Clicking on the online user guide link for Money 2004 >found at > >http://www.microsoft.com/money/support/manual/ > >produces no results. It behaves lik...

Money file gone in Vista
I read through the newsgroups and saw a few references, BUT in my case the file just isn't there. This happened twice in about 4 months in Vista 64 bit with Money 2007. I restore from a backup then all is well. Any suggestions, or should I somehow try to report it? Thanx, Tony "Tony Linguini" <pccarguy@nospam.hotmail.com> wrote in message = news:OoQUInUoHHA.1240@TK2MSFTNGP04.phx.gbl... >I read through the newsgroups and saw a few references, BUT in my case = the=20 > file just isn't there. This happened twice in about 4 months in Vista = 64 bit=20 > with ...

Save each file in a folder as a filtered HTML file and also as a PDF file
I submitted this to the word.programming but wonder if this is the right NG. I need to open each file (.doc) that is in a certain folder and then save it both as a filtered HTML and also as a PDF. I wonder if that can be automated somehow. I have no idea how to program word so I'm afraid that I could spend much time learning how to, only to find out it can't be done. If it is a reasonable thing to do I'd really appreciate a sample of something similar so I can get orientated and know what to look up. Thank in advance Answered in the other group! ...

Can't Close File
I didn't write down the message at the time, but on several occasions I get the message "Can't Close File - File Is In Use". Then I click on Save again, and it saves it just fine. Then if I open and save it again immediately, I don't get the message. It's as though the original save command was issued before something else that's going on has completed. Yes, I've searched the KB, and found nothing. Regretably I can't remember whether it's always the same file, but I don't think so. It just happens occasionally, but it's unnerving when it...

DAO35 & MSAccess 97 file format
Hi I am trying to open an MS-Access 97 D/B file with DAO350.DLL, it is working fine, if i try to open a MS-Access[2000 file format] file , by calling OpenDatabase method from DAO350.dll, the program is throwing exception, Please can some one tell how to handle this? The MS-Access dtabase 2000 is supported by DAO360.dll & DAO350.dll -OpenDatabase method. Any idea why the exception for DAO350.DLL & 97 file format MS-Access database file ...

Find a Dir and File
I need to import a .txt delimited file using VBA in A2003. The file name will be different each import time except for the .txt extension, and the field structure will always be the same.. Like 040907.txt or 041007.txt I'm planning to use the TransferText method, along with an Import Specification file. The problem I can't figure out is how to code for the user to go out to the G: drive, find the specific filename, and capture the Path and Filename as a variable to pass on to my TransferText FileName argument. Would appreciate any help. Thankyou, John Hi John, The code here ...

when opening an excel file, two files open
When I open up an Excel file from Explorer, two excel documents open up. One document is called "Book 1" and the other is the actual document that I intended to open. How do I prevent this from happening? Brian Same answer I posted Dec 9th. Did it not work for you? Brian To prevent Book1 from opening you can append /e to your shortcut for opening Excel. "C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\EXCEL.EXE" /e Alternative to the above............ Go to Start>Settings>Folder>Options>File Types. Scroll down to MS Excel Worksheet. Then if running Win98...

two backup files
I have two backup files that are not syncd - for example, one backup file has transactions from 2002 to 2004 and then another file has transactions from 2004 to current. I would like to consolidate these two files so that I have an entire chronilogical file from 2002 to current. Suggestions? That would be difficult, messy, and unlikely to produce satisfactory results. I don't advise it. For one thing, if you have investments, the one with transactions 2004 to current probably has investment transactions predating 2004. Those would be duplicates of the 02-04 file. Also, the beginn...

Weird problem saving a file
Hey guys. This one is hard to explain. I have a file tha automatically pulls different numbers from financial statement that i in Excel format. It pulls the numbers and does about a hundre calculations for me automatically. it saves me a ton of time. download the financial statement every month and then use this file t analyze it. My problem is that I can't figure out how to do a "Save As" that keep the numbers for that one month without autopopulating the numbers nex month. As in, I can't save different months because they al autopopulate with the newest month FS....

How to create a file in vista?
I used example code in vista but ruturn code is INVALID_HANDLE_VALUE How to create a file in vista? HANDLE hFile = CreateFile(_T("C:\\MyFile.DAT"), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) AfxMessageBox(_T("Couldn't create the file!")); else { // Attach a CFile object to the handle we have. CFile myFile(hFile); static const char sz[] = "Hockey is best!"; // write string, without null-terminator myFile.Write(sz, lstrlen(sz)); // We can call Close() explic...

How to insert a litlle jpg-file into Access 2003?
Hi. Is it possible to import small jpg-files to database? hanski Yes, you should be able to import it and then use an unbound object frame to put it in in your form or reports. -- Milton Purdy ACCESS State of Arkansas "hanski" wrote: > Hi. > > Is it possible to import small jpg-files to database? > > > hanski > . > On 11 joulu, 16:21, golfinray <golfin...@discussions.microsoft.com> wrote: > Yes, you should be able to import it and then use an unbound object frame= to > put it in in your form or reports. ...

how can i import a file from microsoft publisher to Outlook
Can i have a Publisher file that i can open in Outlook. Dear Dahiana, You can send your publication as an e-mail if your default e-mail client is Microsoft Outlook´┐Ż version 2002 http://www.microsoft.com/office/previous/xp/columns/column16.asp -- Oliver Vukovics Share Outlook PST files without Exchange: Public ShareFolder Share all your contacts, calendars or e-mails in a workgroup http://www.publicshareware.com "Dahiana" <Dahiana@discussions.microsoft.com> schrieb im Newsbeitrag news:42A65592-605E-4AB8-9728-0DBE8025A181@microsoft.com... > Can i have a Publisher file ...

GLB Exchange resynchronization file
What is the file construction details ? The file content starts with "Hq", but what is its internal format ? i want to build a program that reads the content of the GLB files. thx. ...

How to run an executable file
This has to be easy. I want to run an .exe file from within my code, but search in VCE 2008 Help turns up nothing. A quick google turns up the Process.Start() way of doing it. Is this a good way? It should basically start the application, and then all links to the calling app should disappear, leaving two independently running. Thanks in advance! -- Wannabe Geek On 02-01-2010 16:06, wannabe geek wrote: > This has to be easy. I want to run an .exe file from within my code, but > search in VCE 2008 Help turns up nothing. A quick google turns up the > Process.Start()...

Various Excel files into one file
Is there a way to make various Excel Spreadsheet be move to be access to only one Spreadsheet without copying and pasting each file into the that one spreadsheet? Jose Noriega - > Is there a way to make various Excel Spreadsheet be move to be access to > only one Spreadsheet without copying and pasting each file into the that > one spreadsheet? < Edit | Move Or Copy Sheet - Mike www.mikemiddleton.com Hi see: http://www.rondebruin.nl/copy2.htm -- Regards Frank Kabel Frankfurt, Germany "Jose Noriega" <Jose Noriega@discussions.microsoft.com> schrieb im...

coverting iWord.pages file
is there a way to convert a .pages (iWord) file to ms word? Of has anyone encountered an iWorks trial software that will run on PC? Sorry, AFAICS the only easy way is to open the file in Pages on Mac, then save in one of the formats that Word can read. The best you are likely to be able to do in Word is check Word->Tools->Options->General->COnfirm conversions at open (or the WOrd 2007 equivalent) and see if the "Recover text from any file" converter will help. Beyond that, it depends on high you need the conversion quality to be. I had a look around...