|
-
Aug 10th, 2005, 05:33 PM
#1
Thread Starter
PowerPoster
progress?
Hi there. Hope someone can help!
I kind of know how to make a progress bar but I do not know how it will work for this...
Basically, my app checks for an update on the net. if there is, it will download it. It writes that download to a memory stream then to file stream.
it gets the length of bytes from the update website... it then writes that to the memory stream to construct the file.
during this process, how can i make a progress bar on how much it has progressed throughout the entire procedure?
Code:
MemoryStream fileMemoryStream = new MemoryStream();
DirectoryInfo dirInfo = new DirectoryInfo(theLinkToFilePath);
string theFileNameOfUpdate = theLinkToFilePath.Substring(theLinkToFilePath.LastIndexOf("/") + 1);
string theDirsToCreate = theLinkToFilePath.Substring(0, theLinkToFilePath.LastIndexOf("/"));
Directory.CreateDirectory(currentClientStartupPath + @"\" + theDirsToCreate);
FileStream theFileStream = new FileStream(currentClientStartupPath + "\\" + theDirsToCreate + @"\" + theFileNameOfUpdate, FileMode.Create, FileAccess.ReadWrite);
int len = (int)theWebUpdateObject.GetFileLen(theLinkToFilePath);
Byte[] theByteArray = new byte[len];
theByteArray = theWebUpdateObject.SendFileToClient(theLinkToFilePath);
fileMemoryStream.Write(theByteArray, 0, len);
fileMemoryStream.WriteTo(theFileStream);
theFileStream.Close();
fileMemoryStream.Close();
that is pretty much how to gets and writes the file... during that i would like the progress bar to show the progress.
how can it be done?
-
Aug 11th, 2005, 05:36 AM
#2
Re: progress?
Set your progress bar's Min and Max values to 0 and 100 then use this formula for the Value property:
PropBar.Value = (int)(MemoryStream.Position / TotalFileSizeInBytes) * 100
I don't live here any more.
-
Aug 11th, 2005, 05:38 AM
#3
Thread Starter
PowerPoster
Re: progress?
thanks
ok.. so where do I place that code? in the same method as the code I posted?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|