Hi,
I have a problem downloading a file .
after i connect to the website and get the stream , i treing to write
the file on the HD.
public void SaveStreamToFil e(string filePath, Stream stream)
{
// If not all data was provided return false;
//if (string.IsNullO rEmpty(filePath ) || stream == null)
// return false;
// System.IO.Strea m gzStream = stream; //= new
System.IO.Strea m()//(stream,
System.IO.Compr ession.Compress ionMode.Decompr ess);
FileStream fs = null;
try
{
byte[] inBuffer = new byte[10000];
int bytesRead = 0;
fs = File.Open(fileP ath, FileMode.Create ,
FileAccess.Writ e, FileShare.Read) ;
while ((bytesRead = stream.Read(inB uffer, 0,
inBuffer.Length )) 0)
{
fs.Write(inBuff er, 0, bytesRead);
}
fs.Flush();
// return true;
}
catch (Exception ex)
{
throw ex;
// ExceptionPolicy .HandleExceptio n(ex, "Global
Policy");
//return false;
}
finally
{
fs.Close();
}
}
webRequest1.Kee pAlive = true;
webRequest1.Coo kieContainer = cookies;
webRequest1.Acc ept =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5";
webRequest1.Hea ders.Set("Accep t-Language",
"en-us,en;q=0.5");
webRequest1.Hea ders.Set("Accep t-Encoding", "gzip,deflate") ;
webRequest1.Hea ders.Set("Accep t-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7 ");
webRequest1.Hea ders.Set("Keep-Alive", "300");
WebResponse myResponse1 = webRequest1.Get Response();
Stream ReceiveStream1 = myResponse1.Get ResponseStream( );
SaveStreamToFil e(@"C:\file.csv ", ReceiveStream1) ;
the problem is that if i want to download a file (as big as 3Mb) it
takes me 40min to do it .
(my internet connection is fast)
please suggest me , how to solve this problem .
Thanks , Rony 5 1848
Havent read the code but a quick thought, the server that is hosting the
file you are downloading, whats its upstream bandwidth?
"rony_16" <ro***********@ gmail.comwrote in message
news:11******** *************@7 5g2000cwc.googl egroups.com...
Hi,
I have a problem downloading a file .
after i connect to the website and get the stream , i treing to write
the file on the HD.
public void SaveStreamToFil e(string filePath, Stream stream)
{
// If not all data was provided return false;
//if (string.IsNullO rEmpty(filePath ) || stream == null)
// return false;
// System.IO.Strea m gzStream = stream; //= new
System.IO.Strea m()//(stream,
System.IO.Compr ession.Compress ionMode.Decompr ess);
FileStream fs = null;
try
{
byte[] inBuffer = new byte[10000];
int bytesRead = 0;
fs = File.Open(fileP ath, FileMode.Create ,
FileAccess.Writ e, FileShare.Read) ;
while ((bytesRead = stream.Read(inB uffer, 0,
inBuffer.Length )) 0)
{
fs.Write(inBuff er, 0, bytesRead);
}
fs.Flush();
// return true;
}
catch (Exception ex)
{
throw ex;
// ExceptionPolicy .HandleExceptio n(ex, "Global
Policy");
//return false;
}
finally
{
fs.Close();
}
}
webRequest1.Kee pAlive = true;
webRequest1.Coo kieContainer = cookies;
webRequest1.Acc ept =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5";
webRequest1.Hea ders.Set("Accep t-Language",
"en-us,en;q=0.5");
webRequest1.Hea ders.Set("Accep t-Encoding", "gzip,deflate") ;
webRequest1.Hea ders.Set("Accep t-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7 ");
webRequest1.Hea ders.Set("Keep-Alive", "300");
WebResponse myResponse1 = webRequest1.Get Response();
Stream ReceiveStream1 = myResponse1.Get ResponseStream( );
SaveStreamToFil e(@"C:\file.csv ", ReceiveStream1) ;
the problem is that if i want to download a file (as big as 3Mb) it
takes me 40min to do it .
(my internet connection is fast)
please suggest me , how to solve this problem .
Thanks , Rony
Hi,
Where is the server hosted?
What performance do you get if you try to download this same file frmo the
browser.
Are you getting any exception?
Is the file compressed when you download it? I see you setup several headers
in the request, what if you do not do it?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"rony_16" <ro***********@ gmail.comwrote in message
news:11******** *************@7 5g2000cwc.googl egroups.com...
Hi,
I have a problem downloading a file .
after i connect to the website and get the stream , i treing to write
the file on the HD.
public void SaveStreamToFil e(string filePath, Stream stream)
{
// If not all data was provided return false;
//if (string.IsNullO rEmpty(filePath ) || stream == null)
// return false;
// System.IO.Strea m gzStream = stream; //= new
System.IO.Strea m()//(stream,
System.IO.Compr ession.Compress ionMode.Decompr ess);
FileStream fs = null;
try
{
byte[] inBuffer = new byte[10000];
int bytesRead = 0;
fs = File.Open(fileP ath, FileMode.Create ,
FileAccess.Writ e, FileShare.Read) ;
while ((bytesRead = stream.Read(inB uffer, 0,
inBuffer.Length )) 0)
{
fs.Write(inBuff er, 0, bytesRead);
}
fs.Flush();
// return true;
}
catch (Exception ex)
{
throw ex;
// ExceptionPolicy .HandleExceptio n(ex, "Global
Policy");
//return false;
}
finally
{
fs.Close();
}
}
webRequest1.Kee pAlive = true;
webRequest1.Coo kieContainer = cookies;
webRequest1.Acc ept =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5";
webRequest1.Hea ders.Set("Accep t-Language",
"en-us,en;q=0.5");
webRequest1.Hea ders.Set("Accep t-Encoding", "gzip,deflate") ;
webRequest1.Hea ders.Set("Accep t-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7 ");
webRequest1.Hea ders.Set("Keep-Alive", "300");
WebResponse myResponse1 = webRequest1.Get Response();
Stream ReceiveStream1 = myResponse1.Get ResponseStream( );
SaveStreamToFil e(@"C:\file.csv ", ReceiveStream1) ;
the problem is that if i want to download a file (as big as 3Mb) it
takes me 40min to do it .
(my internet connection is fast)
please suggest me , how to solve this problem .
Thanks , Rony
hi,
when i download this file through browser, it being downloaded very
fast .
and the server is very fast .
what i do know that this file protected with SSL .
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,
Where is the server hosted?
What performance do you get if you try to download this same file frmo the
browser.
Are you getting any exception?
Is the file compressed when you download it? I see you setup several headers
in the request, what if you do not do it?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"rony_16" <ro***********@ gmail.comwrote in message
news:11******** *************@7 5g2000cwc.googl egroups.com...
Hi,
I have a problem downloading a file .
after i connect to the website and get the stream , i treing to write
the file on the HD.
public void SaveStreamToFil e(string filePath, Stream stream)
{
// If not all data was provided return false;
//if (string.IsNullO rEmpty(filePath ) || stream == null)
// return false;
// System.IO.Strea m gzStream = stream; //= new
System.IO.Strea m()//(stream,
System.IO.Compr ession.Compress ionMode.Decompr ess);
FileStream fs = null;
try
{
byte[] inBuffer = new byte[10000];
int bytesRead = 0;
fs = File.Open(fileP ath, FileMode.Create ,
FileAccess.Writ e, FileShare.Read) ;
while ((bytesRead = stream.Read(inB uffer, 0,
inBuffer.Length )) 0)
{
fs.Write(inBuff er, 0, bytesRead);
}
fs.Flush();
// return true;
}
catch (Exception ex)
{
throw ex;
// ExceptionPolicy .HandleExceptio n(ex, "Global
Policy");
//return false;
}
finally
{
fs.Close();
}
}
webRequest1.Kee pAlive = true;
webRequest1.Coo kieContainer = cookies;
webRequest1.Acc ept =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5";
webRequest1.Hea ders.Set("Accep t-Language",
"en-us,en;q=0.5");
webRequest1.Hea ders.Set("Accep t-Encoding", "gzip,deflate") ;
webRequest1.Hea ders.Set("Accep t-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7 ");
webRequest1.Hea ders.Set("Keep-Alive", "300");
WebResponse myResponse1 = webRequest1.Get Response();
Stream ReceiveStream1 = myResponse1.Get ResponseStream( );
SaveStreamToFil e(@"C:\file.csv ", ReceiveStream1) ;
the problem is that if i want to download a file (as big as 3Mb) it
takes me 40min to do it .
(my internet connection is fast)
please suggest me , how to solve this problem .
Thanks , Rony
Your code is pretty much correct. You're having keep alive turned on
though, and I don't see disposal code on your response. The framework
internals live by the protocol specs for https that say that you can
only have 2 current connections to the same domain over https at the
same time. If you're running this code in succession, or threading it,
you will have problems with one download preventing the other from
downloading. This is the only thing I can think of which would cause a
slow download. You can override this behavior by setting the
ServicePoint.Co nnectionLimit to a higher number, like say 50 or so. I
would also suggest making absolutely sure you have using blocks on
every single declared variable that you can in there as I've seen a lot
of issues just coming from people not realizing that a stream was still
open. You can always packet sniff the download and see what's actually
going on between you and the server under the covers.
Bruce Dunwiddie http://www.csvreader.com
rony_16 wrote:
hi,
when i download this file through browser, it being downloaded very
fast .
and the server is very fast .
what i do know that this file protected with SSL .
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,
Where is the server hosted?
What performance do you get if you try to download this same file frmo the
browser.
Are you getting any exception?
Is the file compressed when you download it? I see you setup several headers
in the request, what if you do not do it?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"rony_16" <ro***********@ gmail.comwrote in message
news:11******** *************@7 5g2000cwc.googl egroups.com...
Hi,
I have a problem downloading a file .
after i connect to the website and get the stream , i treing to write
the file on the HD.
public void SaveStreamToFil e(string filePath, Stream stream)
{
// If not all data was provided return false;
//if (string.IsNullO rEmpty(filePath ) || stream == null)
// return false;
// System.IO.Strea m gzStream = stream; //= new
System.IO.Strea m()//(stream,
System.IO.Compr ession.Compress ionMode.Decompr ess);
FileStream fs = null;
try
{
byte[] inBuffer = new byte[10000];
int bytesRead = 0;
fs = File.Open(fileP ath, FileMode.Create ,
FileAccess.Writ e, FileShare.Read) ;
while ((bytesRead = stream.Read(inB uffer, 0,
inBuffer.Length )) 0)
{
fs.Write(inBuff er, 0, bytesRead);
}
fs.Flush();
// return true;
}
catch (Exception ex)
{
throw ex;
// ExceptionPolicy .HandleExceptio n(ex, "Global
Policy");
//return false;
}
finally
{
fs.Close();
}
}
webRequest1.Kee pAlive = true;
webRequest1.Coo kieContainer = cookies;
webRequest1.Acc ept =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5";
webRequest1.Hea ders.Set("Accep t-Language",
"en-us,en;q=0.5");
webRequest1.Hea ders.Set("Accep t-Encoding", "gzip,deflate") ;
webRequest1.Hea ders.Set("Accep t-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7 ");
webRequest1.Hea ders.Set("Keep-Alive", "300");
WebResponse myResponse1 = webRequest1.Get Response();
Stream ReceiveStream1 = myResponse1.Get ResponseStream( );
SaveStreamToFil e(@"C:\file.csv ", ReceiveStream1) ;
>
the problem is that if i want to download a file (as big as 3Mb) it
takes me 40min to do it .
(my internet connection is fast)
>
please suggest me , how to solve this problem .
Thanks , Rony
>
thanks , i will try it .
shriop wrote:
Your code is pretty much correct. You're having keep alive turned on
though, and I don't see disposal code on your response. The framework
internals live by the protocol specs for https that say that you can
only have 2 current connections to the same domain over https at the
same time. If you're running this code in succession, or threading it,
you will have problems with one download preventing the other from
downloading. This is the only thing I can think of which would cause a
slow download. You can override this behavior by setting the
ServicePoint.Co nnectionLimit to a higher number, like say 50 or so. I
would also suggest making absolutely sure you have using blocks on
every single declared variable that you can in there as I've seen a lot
of issues just coming from people not realizing that a stream was still
open. You can always packet sniff the download and see what's actually
going on between you and the server under the covers.
Bruce Dunwiddie http://www.csvreader.com
rony_16 wrote:
hi,
when i download this file through browser, it being downloaded very
fast .
and the server is very fast .
what i do know that this file protected with SSL .
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,
>
Where is the server hosted?
What performance do you get if you try to download this same file frmo the
browser.
>
Are you getting any exception?
Is the file compressed when you download it? I see you setup several headers
in the request, what if you do not do it?
>
>
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
>
>
>
"rony_16" <ro***********@ gmail.comwrote in message
news:11******** *************@7 5g2000cwc.googl egroups.com...
Hi,
I have a problem downloading a file .
after i connect to the website and get the stream , i treing to write
the file on the HD.
public void SaveStreamToFil e(string filePath, Stream stream)
{
// If not all data was provided return false;
//if (string.IsNullO rEmpty(filePath ) || stream == null)
// return false;
// System.IO.Strea m gzStream = stream; //= new
System.IO.Strea m()//(stream,
System.IO.Compr ession.Compress ionMode.Decompr ess);
FileStream fs = null;
try
{
byte[] inBuffer = new byte[10000];
int bytesRead = 0;
fs = File.Open(fileP ath, FileMode.Create ,
FileAccess.Writ e, FileShare.Read) ;
while ((bytesRead = stream.Read(inB uffer, 0,
inBuffer.Length )) 0)
{
fs.Write(inBuff er, 0, bytesRead);
}
fs.Flush();
// return true;
}
catch (Exception ex)
{
throw ex;
// ExceptionPolicy .HandleExceptio n(ex, "Global
Policy");
//return false;
}
finally
{
fs.Close();
}
}
webRequest1.Kee pAlive = true;
webRequest1.Coo kieContainer = cookies;
webRequest1.Acc ept =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5";
webRequest1.Hea ders.Set("Accep t-Language",
"en-us,en;q=0.5");
webRequest1.Hea ders.Set("Accep t-Encoding", "gzip,deflate") ;
webRequest1.Hea ders.Set("Accep t-Charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7 ");
webRequest1.Hea ders.Set("Keep-Alive", "300");
WebResponse myResponse1 = webRequest1.Get Response();
Stream ReceiveStream1 = myResponse1.Get ResponseStream( );
SaveStreamToFil e(@"C:\file.csv ", ReceiveStream1) ;
the problem is that if i want to download a file (as big as 3Mb) it
takes me 40min to do it .
(my internet connection is fast)
please suggest me , how to solve this problem .
Thanks , Rony
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: No_Excuses |
last post by:
All,
I am interested in reading the text of a web page and parsing it.
After searching on this newgroup I decided to use the following:
******************************* START OF CODE ************************
String sTemp = "http://cgi3.igl.net/cgi-bin/ladder/teamsql/team_view.cgi?ladd=teamknights&num=238&showall=1";
WebRequest...
|
by: just.starting |
last post by:
Hi,
My dot net client downloads files and checks for any new files time to
time. The server is apache2.0.53 server. So what happens is that my
file download thing works fine if I dont try to call any page from the
server while downloading. If I try to call a single page while
downloading a file then the page request goes time out and the...
|
by: just.starting |
last post by:
I am having problem while downloading files from an apache server2.0.53
with php4.3.10.While downloading some files it generally stops after
downloading some specific amount and then stops downloading with the
error message: "the source file could not be read". And the error is
not dependent on the size of the file, as I can download a file of...
|
by: tsbgrp |
last post by:
hi there
i have a problem related to slow downloading speed.the situation is i
have about 60 PC's in a domain.when i ping ISP Gateway from a LAN PC i
get the replies...22, 25,35, 400, 50ms an some times 22, 40, 220, 150,
30, 100ms...I get lot of variations
and when i ping from server PC by disconnecting LAN then i get theese
replies ......
|
by: Mantorok |
last post by:
Hi all
I'm writing a newsgroup reader in C# and I've found the TcpClient to be
extremely slow, when downloading a list of newsgroups for example it runs at
about 8Kb/sec over a 2Mb/sec connection.
Any ideas? Is this just the way it is??
Thanks
Kev
| |
by: rony_16 |
last post by:
Hi,
I have a problem downloading a file .
after i connect to the website and get the stream , i treing to write
the file on the HD.
public void SaveStreamToFile(string filePath, Stream stream)
{
// If not all data was provided return false;
//if (string.IsNullOrEmpty(filePath) || stream == null)
// return false;
// System.IO.Stream...
|
by: bg_ie |
last post by:
Hi,
My company's backend is located at a location with a long address,
something like -
//our_servers/server_number_one/our_department/our_devision/
our_results/our_databases/backend.be
I have tested the very same backend on another server with a sort path
location at it works fine, but at the location above it is extremely
|
by: Geoff Cox |
last post by:
Hello,
I have a page for which downloading into the browser is very slow.
I have tried using YSlow and firebug but is there any way in which I
can actually see which files are taking a long time to be downloaded?
Cheers
Geoff
|
by: cm_gui |
last post by:
Python is slow. Almost all of the web applications written in
Python are slow. Zope/Plone is slow, sloow, so very slooow. Even
Google Apps is not faster. Neither is Youtube.
Facebook and Wikipedia (Mediawiki), written in PHP, are so much faster
than Python.
Okay, they probably use caching or some code compilation -- but Google
Apps...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |