473,378 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 1839
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Todd Cary | last post by:
Some of my clients would like to have a way to update text and tables in their HTML pages without the need for or understanding of complicated updating programs. Does such a program exist? My...
52
by: Gerard M Foley | last post by:
Can one write a webpage which is not displayed but which simply redirects the user to another page without any action by the user? Sorry if this is simple, but I am sometimes simple myself. ...
2
by: The List Man | last post by:
Crontabs for automatic site updates. Does anyone know how to set up a crontab for automatically updating a webpage on a regular basis. We know how to set these to run perl files, but seem to...
1
by: Rene Crespo | last post by:
Hello, Sorry about the length of this explanation! I am using Access 2000 to assist an export sales department keep track of its weekly offers of products to clients. The database already...
5
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
2
by: Sky | last post by:
Hello, The books on C# I have read talk of using the DataSets in disconnected mode, and Adding/Removing/Updating records from it, and letting it handle all the updating on the Database in one...
1
by: rdemyan via AccessMonster.com | last post by:
My App has 10 or so tables that we provide that contains proprietary data. This data will need to be updated once or twice a year. I would like some comments, suggestions on my proposed strategy...
0
by: RG | last post by:
I have a stored procedure which is called by db2 "call ....." statement from ksh script. When running from AIX DB2 v. 9.1.3 environment, after a while the stored procedure starts to hang and...
3
by: myjish18 | last post by:
Hello, We have a DB2 UDB database v8.2.7 (db2 v8.2 fixpak 14) on AIX 5.3 which has Automatic Storage (AS) enabled. We want to disable automatic storage on entire database and/or disable...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.