By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,572 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

Automatic updating.

P: n/a
Hi,

I'm developing an app with automatic version checking and updating. It must
also track what version is installed for each customer in our customer
database. I have made a small client to fetch updated file(s) from the net
and copy over the old files. I figured this must be done since the program
itself will be read/write locked as long as it is running. I have a
progressbar prgDownload that shows the download progress. My main problem
right now is that the download is extremely slow the way I have programmed
it to make it work with the progress bar.

I have also looked into the Application Updater Block
(http://dotnetjunkies.com/WebLog/bsbl...10/16118.aspx), but
I don't think this is applicable to my solution since I need to keep track
of installed versions and I also need some custom checking on when updates
are needed.

Anyone have any suggestions to how I can speed up the download? Or perhaps
totally different approaches to what I'm trying to accomplish? Any help will
be greatly appreciated. The speed problem is probably because I read and
write one byte at a time, guess I need to use BufferedReader or something
similar, but I need some code examples to make it work.

Old code without progressbar (fast download):

// // Create a web client.

// WebClient wc = new WebClient();

//

// // The file name.

// string fileName = Application.StartupPath + Path.DirectorySeparatorChar +
"Transport.tmp";

//

// // Delete the old file if it exists.

// File.Delete(fileName);

//

// // Download the file.

// wc.DownloadFile("http://proteria.com/files/Transport.exe",
Application.StartupPath

// + Path.DirectorySeparatorChar + "Transport.tmp");

New code that works with progress bar but is VERY SLOW:

Uri downloadLoc = new Uri("http://proteria.com/files/Transport.exe");

HttpWebRequest req = (HttpWebRequest) WebRequest.Create(downloadLoc);

WebResponse rsp = req.GetResponse();

Stream inStream = rsp.GetResponseStream();

// BufferedStream bs = new BufferedStream(inStream);

File.Delete(Application.StartupPath + Path.DirectorySeparatorChar +
"Transport.tmp");

FileStream fs = File.Create(Application.StartupPath +
Path.DirectorySeparatorChar + "Transport.tmp");

prgDownload.Properties.Step = 1;

prgDownload.Properties.PercentView = true;

prgDownload.Properties.Maximum = (int)(rsp.ContentLength/4096);

prgDownload.Properties.Minimum = 0;
int i = 0;

while(true)

{

int i = inStream.Read();

if(i == -1)

break;
fs.WriteByte((byte)i);

prgDownload.Increment(70);

prgDownload.Update();

}
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Trygve,

I'm not sure if you can wait, but have you checked out the ClickOnce
solution that is going to be delivered with .NET 2.0? It will address all
of the needs that you have, with minimal code.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hi,

I'm developing an app with automatic version checking and updating. It
must
also track what version is installed for each customer in our customer
database. I have made a small client to fetch updated file(s) from the net
and copy over the old files. I figured this must be done since the program
itself will be read/write locked as long as it is running. I have a
progressbar prgDownload that shows the download progress. My main problem
right now is that the download is extremely slow the way I have programmed
it to make it work with the progress bar.

I have also looked into the Application Updater Block
(http://dotnetjunkies.com/WebLog/bsbl...10/16118.aspx),
but
I don't think this is applicable to my solution since I need to keep track
of installed versions and I also need some custom checking on when updates
are needed.

Anyone have any suggestions to how I can speed up the download? Or perhaps
totally different approaches to what I'm trying to accomplish? Any help
will
be greatly appreciated. The speed problem is probably because I read and
write one byte at a time, guess I need to use BufferedReader or something
similar, but I need some code examples to make it work.

Old code without progressbar (fast download):

// // Create a web client.

// WebClient wc = new WebClient();

//

// // The file name.

// string fileName = Application.StartupPath + Path.DirectorySeparatorChar
+
"Transport.tmp";

//

// // Delete the old file if it exists.

// File.Delete(fileName);

//

// // Download the file.

// wc.DownloadFile("http://proteria.com/files/Transport.exe",
Application.StartupPath

// + Path.DirectorySeparatorChar + "Transport.tmp");

New code that works with progress bar but is VERY SLOW:

Uri downloadLoc = new Uri("http://proteria.com/files/Transport.exe");

HttpWebRequest req = (HttpWebRequest) WebRequest.Create(downloadLoc);

WebResponse rsp = req.GetResponse();

Stream inStream = rsp.GetResponseStream();

// BufferedStream bs = new BufferedStream(inStream);

File.Delete(Application.StartupPath + Path.DirectorySeparatorChar +
"Transport.tmp");

FileStream fs = File.Create(Application.StartupPath +
Path.DirectorySeparatorChar + "Transport.tmp");

prgDownload.Properties.Step = 1;

prgDownload.Properties.PercentView = true;

prgDownload.Properties.Maximum = (int)(rsp.ContentLength/4096);

prgDownload.Properties.Minimum = 0;
int i = 0;

while(true)

{

int i = inStream.Read();

if(i == -1)

break;
fs.WriteByte((byte)i);

prgDownload.Increment(70);

prgDownload.Update();

}

Nov 16 '05 #2

P: n/a
Hi,

and thanks for your answer. Yes, I'm aware of the ClickOnce solution.
Actually we were hoping to use Zero Touch Deployment, but that didn't seem
mature enough at the time. No status indicator when downloading, slower
performance etc. Basically, we can't wait, but do you have any idea when
..NET 2.0 will be out? We have sceduled a beta release at the end of the
month...

If you have any suggestions to solve my download issues, I'd be greatful
too.

Cheers,
Trygve

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uJ**************@TK2MSFTNGP10.phx.gbl...
Trygve,

I'm not sure if you can wait, but have you checked out the ClickOnce
solution that is going to be delivered with .NET 2.0? It will address all
of the needs that you have, with minimal code.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Trygve Lorentzen" <trygveloAThaldenDOTnet> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hi,

I'm developing an app with automatic version checking and updating. It
must
also track what version is installed for each customer in our customer
database. I have made a small client to fetch updated file(s) from the net and copy over the old files. I figured this must be done since the program itself will be read/write locked as long as it is running. I have a
progressbar prgDownload that shows the download progress. My main problem right now is that the download is extremely slow the way I have programmed it to make it work with the progress bar.

I have also looked into the Application Updater Block
(http://dotnetjunkies.com/WebLog/bsbl...10/16118.aspx),
but
I don't think this is applicable to my solution since I need to keep track of installed versions and I also need some custom checking on when updates are needed.

Anyone have any suggestions to how I can speed up the download? Or perhaps totally different approaches to what I'm trying to accomplish? Any help
will
be greatly appreciated. The speed problem is probably because I read and
write one byte at a time, guess I need to use BufferedReader or something similar, but I need some code examples to make it work.

Old code without progressbar (fast download):

// // Create a web client.

// WebClient wc = new WebClient();

//

// // The file name.

// string fileName = Application.StartupPath + Path.DirectorySeparatorChar +
"Transport.tmp";

//

// // Delete the old file if it exists.

// File.Delete(fileName);

//

// // Download the file.

// wc.DownloadFile("http://proteria.com/files/Transport.exe",
Application.StartupPath

// + Path.DirectorySeparatorChar + "Transport.tmp");

New code that works with progress bar but is VERY SLOW:

Uri downloadLoc = new Uri("http://proteria.com/files/Transport.exe");

HttpWebRequest req = (HttpWebRequest) WebRequest.Create(downloadLoc);

WebResponse rsp = req.GetResponse();

Stream inStream = rsp.GetResponseStream();

// BufferedStream bs = new BufferedStream(inStream);

File.Delete(Application.StartupPath + Path.DirectorySeparatorChar +
"Transport.tmp");

FileStream fs = File.Create(Application.StartupPath +
Path.DirectorySeparatorChar + "Transport.tmp");

prgDownload.Properties.Step = 1;

prgDownload.Properties.PercentView = true;

prgDownload.Properties.Maximum = (int)(rsp.ContentLength/4096);

prgDownload.Properties.Minimum = 0;
int i = 0;

while(true)

{

int i = inStream.Read();

if(i == -1)

break;
fs.WriteByte((byte)i);

prgDownload.Increment(70);

prgDownload.Update();

}


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.