|
Hi,
I have windows app that uploads multiple files from a folder into the database. it takes a few seconds to upload all the files. what I need to do is to display a progress bar for the users to see that the application is still busy uploading the files to the database. I don't know how to do that in C# using Progress Bar control.
Please, can you help or advice on what to do.
Thanks.
|
|
|
|
|
Drop a progress bar on to the form. You can upate the value to indicate the percentage progress, or set the style to Marquee if it's not possible to quantify the progress.
If you wish to do the actual work on a background thread - I have a progressbar and backgroundworker combined here[^].
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Nopo wrote: don't know how to do that in C# using Progress Bar control.
You can use BackGroundWorker r in C#
Sample Ref 1[^]
Sample Ref 2[^]
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Create a background worker in your application.
It has three events that you will want to handle.
.DoWork:
put you code that does the upload file here, at the end of each file report the progress as a percentage ( 100 / totalNumFiles * numFilesUploaded), this is done via BackgroundWorker1.ReportProgress()
.ProgressChanged:
update your progress bar value with the percentage passed as in the event args i.e. ProgressBar1.Value = e.ProgressPercentage
.WorkerComplete:
notify the user that the uploading has been complete or whatever you do after its finished.
Once you have coded these event handlers you can start the upload with BackgroundWorker1.RunWorkerAsync();
As this will start a new thread you will need to pass any data that your uploading code may need as parameters to the above function
i.e
string[] filepaths = {"file1", "file2"};
string destinationPath = "destination path";
BackgroundWorker1.RunWorkerAsync(new object[]{filepaths, destinationPath});
then at the start of your .DoWork event handler you can aquire these value with the following code:
object[] args = (object[])e.Argument;
string[] filepaths = (string[])args[0];
string destinationPath = (string)args[1];
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
i have a windows service and when any exceptions occur then its stopping... is there any way to restart that service automatically when it is stopped...
|
|
|
|
|
|
thans for that.. but is the code in the
public override onstop()
{
//progie code
}
will this function execute when the service is stopped due to abnormal execution such as exception....
|
|
|
|
|
It is unlikely that any event will fire when you get an exception. Your best bet would be to handle an errors and exceptions so your service does not crash. I dont really want to suggest putting the whole service in one try/catch block and doing some restarting code in that but its your choice what approach you take
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
ok... if you are free can u tell will the service crash when the exception eccurs in the service...and i am sending the data from systems on the network to the service. and when the number of clients get more i get the exception "The IAsyncResult object was not returned" at the client side and insted of client crashing my service crashes....can i get some help with this...
|
|
|
|
|
Im afraid i can not give you any detailed help on this subject but it appears that you have a problem handling your connections in your service. the service should ideally receive a request for a connection, check anything that may stop it using a new connection, and then report back to the client with a success/fail message in regards to the connection request.
EDIT:
max.4u wrote: will the service crash when the exception eccurs in the service...
Yes the service will crash just like any application would if an unhandled exception is thrown
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
its ok... i wil once again review my code in the service... and do u know whats the maximum number of connections the tcp listener can handle without queing....?
|
|
|
|
|
It appears to vary based on the OS, i just had a quick look at this[^]
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
thanks... and if i am not bothering you.... when i create a tcp socket and connect to the server and when the connection is established then is it regarded as the tcp connection or a socket connection..?
|
|
|
|
|
Im not sure but i would say it would be both
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi all,
How to write a xml file into Remote URL using its NetWorkCredentials(userid & password) ?
Please suggest me.
Thanks in advance
cheers
kvsekhar
|
|
|
|
|
So... you want to upload a file to a server? you could create an FTP for the server
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Thanks for your suggestion.
Is it not possible using DataSet.WriteXml(url) ?
because I could able to read xml file from url by following code
XmlUrlResolver resolver = new XmlUrlResolver();<br />
NetworkCredential nc = new NetworkCredential("id", "pwd");<br />
resolver.Credentials = nc;<br />
<br />
Uri myUri = new Uri("http://domain/Assessments/Expenses.xml");<br />
Stream s = (Stream)resolver.GetEntity(myUri, null, typeof(Stream));<br />
<br />
XmlTextReader xmlTextReader = new XmlTextReader(s);<br />
<br />
XmlDataDocument xdoc1 = new XmlDataDocument();<br />
xdoc1.DataSet.ReadXml(xmlTextReader, XmlReadMode.Auto);<br />
<br />
DataSet ds = xdoc1.DataSet;
How this logic will be applied for Writing XML to URL ?
|
|
|
|
|
im not sure if it is possible to write to a file like you are suggesting, and if it was possible it would more than likely require permissions to be set on the server for that kind of write access.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi,
I'm trying to copy a URL to clipboard by using following code
Clipboard.SetText("http://somewhere.com" ,TextDataFormat.Html );
But nothing comes out, essentially i want to copy a URL and when i paste to Word or some place it should come out with Blue underlined i.e it should be a link.
Thanks in advance....
|
|
|
|
|
after a brief test it would appear that word expects a paste to be in the format of 'Text' so it will paste only the last 'Text' object on the clipboard. Setting the TextDataFormat to Html will therefore not paste into word. If you change it to text it will paste into word and word will auto handle the fact that it is a link when you hit 'enter'.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Your URL is not a HTML link. Try
Clipboard.SetText("<a href=\"http://somewhere.com\">http://somewhere.com</a>" ,TextDataFormat.Html);
|
|
|
|
|
Hi, I had small application of BHO, through which I can retrieve the PDF files from cache using DocumentComplete and NavigateComplete2 Events of webbrowser. To get the PDF filepath, I used a filter of following:
http://theagussantoso.blogspot.com/2008/11/get-temporary-internet-explorer-files.html
The url can be obtained from the parameters of respective events.
but when I had retrived the PDF file copy through the filter present in above link, I was unable to get the URL through the events.
How can I get the copy of the pdf file when it is opened on IE?
|
|
|
|
|
why dont you check one of your many other posts on the subject? If you didnt get an answer in them, then dont repost. Go work it out for yourself.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
get the .pdf url using this
http://www.omegacoder.com/?p=63
and download anywhere you want...
|
|
|
|
|
Hi Export
Pls Help Me I am Making dll and User Control in C#.NET.
i Want That My Dll and USer Control Not Used By Another Person.
|
|
|
|