i want to download multiple file and want to show multiple progress bar for each file download progress.i got a code which can download file at a time but i want to start download many files at a time and also like to show progress bar for each file progress
suppose i have one textbox where i will put url and when i click on download button then download will start and a progress bar will be show for showing that file download progress. the same if i put another url in textbox and click on download button then another file download start and another progress bar will be shown to show that file download progress. i want that each file will be downloading in separate thread means my program will be multi threaded.
the code i have for downloading one file at a time.please guide me what to change in code to achieve my goal. thanks
Tried to run this program to save a screensaver but it doesnt seem to work.
The screensaver is generated from a form and this portion of the code which is for the "save" button creates an object with 0 bytes.
privatevoid button6_Click(object sender, EventArgs e)
//Open File Dialog to load image files
saveFileDialog1.FileName = "";
saveFileDialog1.Title = "Images";
//Filter the filedialog, so that it will show only the mentioned format images
saveFileDialog1.Filter = "screensaver.scr(*.scr)|*.scr";
if (saveFileDialog1.FileName.ToString() != "")
System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();
pictBox1.ImageLocation = saveFileDialog1.FileName.ToString();
//OriginalImage = new Bitmap(saveFileDialog1.FileName.ToString());
savefile.Enabled = true;
privatevoid pictBox1_Click(object sender, EventArgs e)
Your code doesn't make any sense at all. You're letting the user pick a ".SCR" file, which is the extension used by screen saver executable files. Then you're trying to display the contents of that file in a picturebox?? WHAT?? You can't do that as a .SCR file is EXECUTABLE, NOT IMAGE DATA!
And, a little pet peeve of mine ... You're calling .ToString() on the FileName property. FileName returns A STRING, so why are you calling .ToString on a String???
Define "fail". What does it do and what's expected?? Any error messages?? Is the component that's calling your code single-threaded? Multi-threaded? Is the thread that's calling your code the UI (startup) thread?
I finally solve it by using CLR . I new a progress form in the clr wapper and then callback it in c++, and all these are compiled to DLL and imported to C#. it runs well. But i don't understant why the C# progress form will fail！
The typecast operation assumes that the object is of type or subclasses from the target type.
So in the above statement a is assumes needs to have string in it's inheritance hierarchy
You should try the above statement in your C# IDE. If 'a' is of type int or float (or anything non-string), the compiler throws an error since it would be a invalid typecast.
Midnight Ahri wrote:
txtValue = a.ToString();
a.ToString call the ToString method that every class inherits from the System.Object[^] class. It does not typecast, it returns a new string representation.
a.ToString would throw a null reference exception if a is null
Midnight Ahri wrote:
txtValue = Convert.ToString(a);
Convert.ToString[^] returns String.Empty in case the object passed to it is null, otherwise it first checks for IConvertible and IFormattable ToString implementations in the object and uses them. Finally if those are it functions the same as the object's ToString.
"It was when I found out I could make mistakes that I knew I was on to something."
"Philosophy is a study that lets us be unhappy more intelligently."