|
I try this method and it's work
string[] spliter = fileName.Split(new char[]{'\\'});
-thanks for ur support
Peter
|
|
|
|
|
I seriously doubt it's homework help he's asking.
Cheers,
Vikram.
Zeppelin's law: In any Soapbox discussion involving Stan Shannon, the probability of the term "leftist" or "Marxist" appearing approaches 1 monotonically.
Harris' addendum: I think you meant "monotonously".
Martin's second addendum: Jeffersonian... I think that should at least get a mention.
|
|
|
|
|
Oh, no, most assuredly not.
|
|
|
|
|
Hey all i am trying to make an application which can read text from an image. I am able to read image with OCR but the problem is that i have to read only information written on a label which is dispatched manually on the document before scanning. First i have to search that label through out the image and then check if it is straight or not if it is not then i have to make it straight to make it readable for my OCR.
I am seriously in a big trouble with this thing so if anyone can help me i will appreciate your concern .
|
|
|
|
|
Sounds like a major task to me. You can use edge detection or segmentation to try to work out where your label is, perhaps. You can then use this to work out if the label is straight, and perform a rotation.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello
I have a lengthly process which takes sometime couple of minutes. I like to update the statusbar to give some feedback to the user. When I tried to update the label of a statusstip from inside a lengthly loop, statusstrip does not show the updated result until it finishes the all iteration.
Here is my experiemental function.
for (int i = 1; i <= 50000; i++)<br />
{<br />
System.String str = "Iteration # ";
str += i.ToString();<br />
<br />
if ( (i % 1000) == 0)<br />
{<br />
toolStripStatusLabel1.Text = str;
}<br />
<br />
}<br />
When I run this function, it just display the final result which show "Iteration # 50000". It does not show any intermediate iteration.
Is it blocking the thread? Even though I put time consuming operation inside the function, still it does not show the intermediate statusstrip update.
Does any body know, how I can update the lable of a statusstrip to update the iteration number within a loop.
Thank you in advance.
|
|
|
|
|
According to your experimental function provided, it should work. Is the real function similar in logic and sequence to this one? Also, I would clear the text then re-set it (This is not a solution to your problem, but recommendation.)
Normally operation which take so long can be put into a separate thread and provide feedback to user at same time in a different thread.
|
|
|
|
|
Yes, real function is same as this one. statusbar only update once it finishes the loop, does not updata any intermediate iteration. My guess is that, UI thread might be freeze until loop finishes. Otherwise I am not sure why it does not update in between.
Still looking for some more help.
Thank you.
|
|
|
|
|
I am not sure where you are initiating the function from. Is it in an event handler? In any case try the following and it should work.
The idea is to create a thread and ask the thread to do some work for you--in your case do the loop. Then ever 100 iteration ask the form to update itself using a delegate.
You should improve this code as per your need but here it is anyways.
public delegate void UpdateLabel();
private Thread loopThread = null;
private string str;
private void button1_Click(object sender, EventArgs e)
{
loopThread = new Thread(new ThreadStart(DoTheLoop));
loopThread.Start();
//aThread.Join();
}
private void DoTheLoop()
{
for (int i = 1; i <= 500000; i++)
{
str = "Iteration # "; // deliberately created inside the loop
str += i.ToString();
if ((i % 100) == 0)
{
//toolStripStatusLabel1.Text = string.Empty;
//toolStripStatusLabel1.Text = str; // Update statusstrip lebel every 1000 iteration.
// Ask the form to Invoke the delegate and ask it to update the label
this.Invoke(new UpdateLabel(UpdateStatusStrip));
}
// ask the loopThread to sleep for a while so processor can do something else
Thread.Sleep(10);
}
}
private void UpdateStatusStrip()
{
toolStripStatusLabel1.Text = string.Empty;
toolStripStatusLabel1.Text = str; // Update statusstrip lebel every 1000 iteration.
}
Let me know if you have any questions.
|
|
|
|
|
Hi
Thanks for your advice. I tried your idea. It works but it does not show all the updates instead it skips many updates. when I wrote === if ((i % 10 ) == 0) == this condition, it does not show all 10, 20 ,30 ..... etc. Sometimes it jumps from 12450 to 16240 (as an example). It looks like before updating one call, loops continue and many calls are discarded because previous one still not finish and when one updating finish, it does not attemp to update next one instead updating the current one.
I tried another idea from another poster from this thread and he suggested to use Application.DoEvents() and it works fine and shows all the updates sequentially.
Thank you for your advice.
|
|
|
|
|
Hi,
if all this code is running on the GUI thread (say inside a button click handler),
then it is normal the GUI is dead until your code finishes, at which point it would
show the final status text only. You could fix that by adding a line
Application.DoEvents() after changing label.Text (this is a dangerous
hack, if your code gets re-entered a stack overflow may occur, so disable the
button that started this for as long as it takes).
if all this code is supposed to run on a separate thread (in an attempt to keep
the GUI alive), then you need to use Control.InvokeRequired and Control.Invoke
to update any GUI component.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thank you for your suggession. I tried your idea and it works in my test case.
|
|
|
|
|
Hi,
I have a class which should return an xml file to a client. The client in this case will use IE to display the contents.
What type should I return to the client so it is the friendliest? In other words I do not want the client to have to write too much code just to see the contents.
Thanks
|
|
|
|
|
The best thing to do is to return the XML as a string . The client can then do whatever it wants with it. In your case, the XML can be written out in a HTTP Response. IE will display it using its own XML Viewer.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi Paul,
Thanks for the reply. Here is what I am doing--pretty simple.
I have a class which writes records to an xml file. It has one public method called GetXmlContents() which will return some type (you reccommended a string). The client is a simple Windows Form which has a button Called "View Xml". Within the button's click handler I want to display the contents using IE.
How can I do this?
|
|
|
|
|
This link[^] shows you how to invoke IE from a .NET app and get it to display a document. In your case, you would need to save the XML to a file and then pass the absolute system path to your XML file in the url argument.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
|
Yes
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thank you, but what does it do that VS2005 doesn't do or doesn't do as well that warrants a purchase?
Thanks again.
|
|
|
|
|
Read this article[^].
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Purchase? Go to your local roll-out event and get it free.
|
|
|
|
|
Im trying to use an active port to send tcp packets..
i know that its possible because the program WPE Pro do it..
WPE Pro attach some process and get all packets that pass through this process..
and use this connection to send edited packets..
how i do it?
sorry bad English =P
thankz..
msn: julinn@msn.com
|
|
|
|
|
Hi
I am creating dll using C#. I made the research and little bit confused with following:
1) does all the classes need Guid?
2) Does all the class need interface classes? or can I have just regular class without interface and Guid?
[Guid("....")]
public interface myclass_interface
{
....
}
[Guid("...."),
ClassInterface(ClassInterfaceType.None)]
public class myclass_class:myclass_interface
{
..
}
3) Can library have static function/procedures so other classes can call them directly?
Thank you.
|
|
|
|
|
1 - Not unless you want to create a COM dll
2 - depends, are you creating a COM dll ?
3 - I don't see why not
Why do you want to create a COM dll, or are you thinking you have to ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm making an Instant Messenger using my new knowledge of Sockets. When the client connects to the host, it tells the host its username. If it's okay (not in use), the client asks for the list of online users. The host replies with an array of bytes and it's converted into an array of strings. I checked the values in the array for set. Now since I would get a cross-threaded call exception I used lsb_users.Invoke so that it would execute on the right thread, (see code):
public void AddUsernameToList(string username)<br />
{<br />
if (this.lsb_users.InvokeRequired)<br />
{<br />
this.lsb_users.Invoke(new MethodInvoker(delegate { AddUsernameToList(username); }));<br />
return;<br />
}<br />
this.lsb_users.Items.Add(username);<br />
}
I set a breakpoint on "this.lsb_users.Items.Add (username)" and it is adding, I hover over Items and it says there are two (which is correct: host username and client username). However in the form there's nothing in the list. Would there be some reason for the listBox not to update? Also something extra: when a client connects to the host it updates the same listbox on its end and it works just fine.
[Edit]
I have a Room class which extends Form, the Room class has the listbox mentionned above as well as the method mentionned above.
HostRoom extends Room and ClientRoom extends Form so the same method is being called. For some reason in ClientRoom nothing is happening.
[/Edit]
Thanks.
|
|
|
|