469,085 Members | 1,039 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,085 developers. It's quick & easy.

Automatic updating.

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
2 1668
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
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.

Similar topics

3 posts views Thread by Todd Cary | last post: by
52 posts views Thread by Gerard M Foley | last post: by
2 posts views Thread by The List Man | last post: by
1 post views Thread by Rene Crespo | last post: by
1 post views Thread by rdemyan via AccessMonster.com | last post: by
reply views Thread by RG | last post: by
3 posts views Thread by myjish18 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.