Why am I getting in the textBox as results the same file name all the time?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I start by searching for a file name. Once a find it, I look for other files. The first file is an .xls file, which is like a signature that Im in the right directory. Then I get all the xml files in this directory.
I put a breakpoint on the line:
<pre class="lang-cs prettyprint
Code:
<span class="typ BeginInvoke<span class="pun (<span class="kwd new<span class="pln  <span class="typ Action<span class="pun (()<span class="pln  <span class="pun =><span class="pln  textBox1<span class="pun .<span class="typ AppendText<span class="pun (<span class="pln pResult<span class="pun [<span class="pln i<span class="pun -<span class="lit 1<span class="pun ].<span class="typ FullName<span class="pun +<span class="typ Environment<span class="pun .<span class="typ NewLine<span class="pun )));<span class="pln <br/>
[/code]
and I see 4 xml files:

danny.xml adi.xml yaron.xml shelly.xml
But if I let the program run without any breakpoint then I only see the 3rd file in the List 4 times:

yaron.xml yaron.xmlyaron.xmlyaron.xml
Can somone please point out why that might be happening?
<pre class="lang-cs prettyprint
Code:
<span class="kwd public<span class="pln  <span class="kwd void<span class="pln  <span class="typ Search<span class="pun (<span class="kwd string<span class="pln  strExtension<span class="pun ,<span class="pln <br/>                            <span class="typ DirectoryInfo<span class="pln  di<span class="pun ,<span class="pln <br/>                            <span class="typ List<span class="pun <<span class="typ FileSystemInfo<span class="pun ><span class="pln  pResult<span class="pun )<span class="pln <br/>        <span class="pun {<span class="pln <br/>            <span class="kwd try<span class="pln <br/>            <span class="pun {<span class="pln <br/><br/>                <span class="kwd foreach<span class="pln  <span class="pun (<span class="typ FileInfo<span class="pln  fi <span class="kwd in<span class="pln  di<span class="pun .<span class="typ GetFiles<span class="pun ())<span class="pln <br/>                <span class="pun {<span class="pln <br/>                    <span class="kwd if<span class="pln  <span class="pun (<span class="typ InvokeRequired<span class="pun )<span class="pln <br/>                    <span class="pun {<span class="pln <br/>                        <span class="typ BeginInvoke<span class="pun (<span class="kwd new<span class="pln  <span class="typ Action<span class="pun (()<span class="pln  <span class="pun =><span class="pln  label2<span class="pun .<span class="typ Text<span class="pln  <span class="pun =<span class="pln  fi<span class="pun .<span class="typ Name<span class="pun ));<span class="pln <br/>                    <span class="pun }<span class="pln <br/>                    <span class="kwd if<span class="pln  <span class="pun (<span class="pln fi<span class="pun .<span class="typ Name<span class="pln  <span class="pun ==<span class="pln  <span class="str "MessageLog.xsl"<span class="pun )<span class="pln <br/>                    <span class="pun {<span class="pln <br/>                        <span class="kwd foreach<span class="pln  <span class="pun (<span class="typ FileInfo<span class="pln  fii <span class="kwd in<span class="pln  di<span class="pun .<span class="typ GetFiles<span class="pun ())<span class="pln <br/>                        <span class="pun {<span class="pln <br/>                        <span class="kwd if<span class="pln  <span class="pun (<span class="pln fii<span class="pun .<span class="typ Extension<span class="pln  <span class="pun ==<span class="pln  strExtension<span class="pun )<span class="pln <br/>                            pResult<span class="pun .<span class="typ Add<span class="pun (<span class="pln fii<span class="pun );<span class="pln <br/>                        <span class="pun }<span class="pln <br/>                        <span class="kwd if<span class="pln  <span class="pun (<span class="typ InvokeRequired<span class="pun )<span class="pln <br/>                        <span class="pun {<span class="pln <br/>                            <span class="typ BeginInvoke<span class="pun (<span class="kwd new<span class="pln  <span class="typ Action<span class="pun (()<span class="pln  <span class="pun =><span class="pln  textBox1<span class="pun .<span class="typ AppendText<span class="pun (<span class="str "Number Of History Files Found: ===> "<span class="pln  <span class="pun +<span class="pln  pResult<span class="pun .<span class="typ Count<span class="pun .<span class="typ ToString<span class="pun ()<span class="pln  <span class="pun +<span class="pln  <span class="typ Environment<span class="pun .<span class="typ NewLine<span class="pun )));<span class="pln <br/>                        <span class="pun }<span class="pln <br/>                        <span class="kwd for<span class="pln  <span class="pun (<span class="kwd int<span class="pln  i <span class="pun =<span class="pln  <span class="lit 0<span class="pun ;<span class="pln  i <span class="pun <<span class="pln  pResult<span class="pun .<span class="typ Count<span class="pun ;<span class="pln  i<span class="pun ++)<span class="pln <br/>                        <span class="pun {<span class="pln <br/>                            <span class="kwd if<span class="pln  <span class="pun (<span class="typ InvokeRequired<span class="pun )<span class="pln <br/>                            <span class="pun {<span class="pln <br/>                                <span class="typ BeginInvoke<span class="pun (<span class="kwd new<span class="pln  <span class="typ Action<span class="pun (()<span class="pln  <span class="pun =><span class="pln  textBox1<span class="pun .<span class="typ AppendText<span class="pun (<span class="pln pResult<span class="pun [<span class="pln i<span class="pun -<span class="lit 1<span class="pun ].<span class="typ FullName<span class="pun +<span class="typ Environment<span class="pun .<span class="typ NewLine<span class="pun )));<span class="pln <br/>                            <span class="pun }<span class="pln <br/><br/>                        <span class="pun }<span class="pln <br/>                    <span class="pun }<span class="pln <br/>                <span class="pun }<span class="pln <br/><br/>                <span class="kwd foreach<span class="pln  <span class="pun (<span class="typ DirectoryInfo<span class="pln  diChild <span class="kwd in<span class="pln  di<span class="pun .<span class="typ GetDirectories<span class="pun ())<span class="pln <br/>                    <span class="typ Search<span class="pun (<span class="pln strExtension<span class="pun ,<span class="pln  diChild<span class="pun ,<span class="pln  pResult<span class="pun );<span class="pln <br/>            <span class="pun }<span class="pln <br/>            <span class="kwd catch<span class="pln  <span class="pun (<span class="typ Exception<span class="pln  e<span class="pun )<span class="pln <br/>            <span class="pun {<span class="pln <br/>            <span class="pun }<span class="pln <br/>        <span class="pun }<span class="pln <br/><br/>        <span class="kwd private<span class="pln  <span class="kwd void<span class="pln  backgroundWorker1_DoWork<span class="pun (<span class="kwd object<span class="pln  sender<span class="pun ,<span class="pln  <span class="typ DoWorkEventArgs<span class="pln  e<span class="pun )<span class="pln <br/>        <span class="pun {<span class="pln <br/>            <span class="typ Search<span class="pun (<span class="str ".xml"<span class="pun ,<span class="pln  dirinf<span class="pun ,<span class="pln  fsi<span class="pun );<span class="pln <br/><br/>        <span class="pun }<span class="pln <br/>
[/code]
<hr class="sig danieli

View the full article
 
Back
Top