|
tanweer akhtar wrote: for (int i = 0; i < Directory.GetFiles(textBox1.Text).Length - 1; i++)
{
object[] file=Directory.GetFiles(textBox1.Text+@"\");
label2.Text = file[i].ToString();
}
timer1.Stop();
}
Yes, it will show only the last file in the list. Try replacing:
label2.Text = file[i].ToString(); with
label2.Text += file[i].ToString(); as this means the new name will be appended to the existing text, rather than replacing it.
You will also want to clear the label2.Text before entering the for loop, and add a newline to the end of the name (or they will all run together in one big line).
Other improvements you may want to do:
1) Change the label for a ListBox - it is better designed for showing lists than a label.
2) Consider using foreach rather than your existing for loop:
DirectoryInfo dir = new DirectoryInfo(dirname);
foreach (FileInfo fi in dir.GetFiles())
{
string filename = fi.FullName;
...
}
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Hello,
I have a datagridview with a horizontal scrollbar. How do I track the scrolled event?
Pritha
|
|
|
|
|
Hi,
Im using C#,WPF in VC++.
For buttons in C# ,i created Delegates and events and i use that in VC++.
But i cannot use Textbox form C# in vc++.I cannot enter any value in that textbox.
Just my assumption is whether i have to use any eventhandler for this. if any means pls provide.
I want to use textbox compulsory.So im struglling in this issue.Pls help.
Anu
|
|
|
|
|
I realise that I could wade through SBs threading 1-5 but I'm as lazy as the next person.
If I fire of a long running thread from the winform, that calls multiple methods in the business object layer which call stored procs and the user closes the form before the thread has completed, what happens to the thread.
I assume it completes the current stored proc and then terminates.
I use the following to call start the thread
var t = new Thread(() => DoTB(iPeriodID));
t.Start();
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well, if by closing the form you mean closing your application, it depends whether the new thread is marked as background or not. If its a background thread, the process ends immediately, if not, the process will live as long as the thread(s) take to execute.
http://msdn.microsoft.com/en-us/library/h339syd0.aspx[^]
As far as the stored proc bit goes, that's in a seperate process so I'd expect it to run to completion once started.
Regards,
Rob Philpott.
|
|
|
|
|
Said threads will now be marked with background - thank you
I'm not worried about the stored procs, I'll just let them run.
Would it be reasonable to put the started thread into a local property and check whether it is alive in the form closing event, then call thread abort if it is still running.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Would it be reasonable to put the started thread into a local property and check whether it is alive in the form closing event, then call thread abort if it is still running.
If you are going to do this, you might want to consider using a BackgroundWorker. That wraps up an asynchronous thread into a convenient class that you can monitor for progress, get callbacks when it completes (including a notification if it ends abnormally with an error) and cancel it in a controlled manner if you want to end it early. There doesn't seem much point in writing your own code to do all that when .NET gives it to you anyway.
|
|
|
|
|
I will need to do some user interface development in the MS environment and although I am an experienced c/c++ developer, I would like to explore the pros and cons of these 2 languages. What are the pros and cons and any suggestions would be appreciated. I hear resharper is a good product to use with c#. Any thoughts on this?
Thanks in advance for any suggestions.
|
|
|
|
|
This will not be a complete list, but rather a simple observation:
If you are doing UI than I think that the developement speed and ease should be enough to convince you to use C#. Don't get me wrong - I have spent my entire life coding C++ (still am), but whenever I need anything with a standard windows UI - then C# is my first choice.
The drawback in some cases is the need to have .NET installed, but today most systems have it anyway
|
|
|
|
|
What do you know about the resharper?
|
|
|
|
|
As I mentioned I mostly do C++, so I have only tried the trial version of resharper. I did like it, and to tell you the truth, everyone I know likes it But you really should give it a go yourself - the trial gives you 10 days to make up your mind.
|
|
|
|
|
Hi, I need to strip out text from a big file and my condition is:
I need to strip out text from below
<div class="a">apple</div>
<p> </p>
<p>red delicious</p>
<div class="b">banana</div>
<p> </p>
<p>riped banana</p>
<div class="c">chives</div>
<p> </p>
<p>fresh green chives</p>
to below
'apple', 'red delicious'
'banana', 'riped banana'
'chives', 'fresh green chives'
so that i can enter each of them to database. I would really appreciate if you could please provide me a regex that could do this. thanks for your help!!!
please note the content of the text is a concatination of multiple html pages.
|
|
|
|
|
repost[^], and no PRE tags once again ==> no help
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
The string you presented is a valid XML (root element is missing).
If performance is not an issue, first add a root element and then you can use XmlDocument or XmlReader to extract the information you needed.
|
|
|
|
|
no only the text i have provided you is valid. the content of the entire csv files has text like
----1----
my contents..
----2----
my content2..
...
...
so could you please help how to extract the data i want?
i have this regex that seem to work to get text between div tag
?<=\<div class=""middlead""\>).*?(?=\</div\>
but i need to get description of apple too. i tried to use below code
string fName = @"data.txt";
StreamReader testTxt = new StreamReader(fName);
string allRead = testTxt.ReadToEnd();
testTxt.Close();
Regex rx1 = new Regex(@"(?<=\<p\> \</p\>).*?(?=\</p\>)", RegexOptions.Singleline);
MatchCollection matches1 = rx1.Matches(allRead);
StreamWriter sw = new StreamWriter(@"realdata.txt");
int count = 0;
foreach (Match match in matches1)
{
sw.WriteLine(count.ToString());
sw.WriteLine(match.ToString());
foreach (Match match1 in matches1)
{
sw.WriteLine(match1.ToString());
}
count++;
}
sw.Close();
}
but some how regex rx1 is not only giving text that i want but its doing greedy matching and try to match everything that has
could you please help as to how can i extract the description of those products.
|
|
|
|
|
Once again, html IS xml. Just use Linq-To-XML to parse it - using regex is a WASTE OF TIME. It's easy - really. All you have to do is man-up and do some frakking research. It's just a few lines of code.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
please note the descript content doesnt have ID so i cant really use dom. any suggestions as to have to get text inside with no id?
|
|
|
|
|
Hi,
Please use below Regex Pattern to get your result.
.*?>([a-zA-Z0-9].*?)<
Which will return the collection of
apple
red delicious
banana
riped banana
chives
fresh green chives
Please let me know if you have any doubt.
|
|
|
|
|
Hi thanks but the text i provided was just an example real text looks something like below and i need a regex for this one below
<p> </p>
<p>red delicious.</p>
<div class="central"><p> </p>
<FORM action="product.asp" method="post" >
<INPUT type="hidden" name="ss" value="3">
<INPUT type="hidden" name="xx" value="xx">
<INPUT type="hidden" name="yy" value="yy">
<input type="image" src="./main/apple.png" value="Click here" />
</form><p> </p>
<p> </p>
<p>riped pear.</p>
<div class="central"><p> </p>
<FORM action="product.asp" method="post" >
<INPUT type="hidden" name="ss" value="3">
<INPUT type="hidden" name="xx" value="xx">
<INPUT type="hidden" name="yy" value="yy">
<input type="image" src="./main/pear.png" value="Click here" />
</form><p> </p>
this one is not working for me as its getting more text than i need
<pre>
(?<=\s\s\<p\>&nbsp;&nbsp;&nbsp;\</p\>\n\t\t\s\s\<p\>).*?(?=\\</p\>\n\t\t\s\s\<div class=""central""\>
</pre>
modified on Wednesday, January 27, 2010 6:14 PM
|
|
|
|
|
not sure why my below regex fails in visual studio editor
(?<=\<p\> \</p\>\n\t+:b+).*(\n\t+:b+\<div class="central"\>)
please note \t+ and :b+ are added because there is exactly 2 tab spaces and 2 white spaces in between the matching text. if I only use
<p\> \</p\>\n\t+:b+ it highlights the preceeding text of the matching text. not sure why by select between group is not working in visual studio. I am running out of ideas please help???
|
|
|
|
|
I tested using regexbuddy
for text
"apple"
with my regex
(?<=a).*?(?=e)
returns "ppl"
now i want to get text in between using below regex
(?<=\<p\> \</p\>).*?(?=\<div class="central"\>)
<p> </p>
<p>red delicious.</p>
<div class="central"><p> </p>
<FORM action="x.asp" method="post" >
<INPUT type="hidden" name="oradvertiser" value="3">
<INPUT type="hidden" name="xx" value="test">
<INPUT type="hidden" name="xy" value="test">
<input type="image" src="./main/apple.png" value="Click here" onmouseout="this.style.border='5px solid silver';" />
</form><p> </p>
<p> </p>
<p>riped pear.</p>
<div class="central"><p> </p>
<FORM action="x.asp" method="post" >
<INPUT type="hidden" name="or" value="3">
<INPUT type="hidden" name="xx" value="test">
<INPUT type="hidden" name="xy" value="test">
<input type="image" src="./main/pear.png" value="Click here" onmouseout="this.style.border='5px solid silver';" />
</form><p> </p>
<p>dummy text</p>
but its not giving me "red delicious" and "riped pear"
could you please help?
|
|
|
|
|
this works
<p>&nbsp;&nbsp;&nbsp;</p>\s+<p>(?<content>.*?)</p>\s+<div class="central">
|
|
|
|
|
good
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
try to use
labelname.refrsh()
after the line u changed text property of the lable
|
|
|
|
|
Hi All ,
I can make application for communication between two pc in same network .But I want to make this communication in following case ,
I have two PC PC1 and PC2 want to communicate them,
PC1 is in network in one company 1, and pc2 is in network of company2 ,PC1 have ip 192.168.1.5 and its router add is 122.xxx.xxx.123 similarly PC2 have ip 192.168.1.5 and its router ip is 123.xxx.xxx.78.
then how should i connect them .
Thank You.
|
|
|
|