File.Exists strangeness

J

Jake

Sorry if this message repeats... I'm going to dumb this version down
to try to get a response more quickly, the last post I made doesn't
seem to have gotten here. I'm developing for a Pocket PC 2003 Phone
Edition.

For debugging purposes only, I'm using File.Exists in a loop with
Thread.Sleep. So it's something vaguely resembling:

[C#:]
==============================
bool hasDoneStuff = false;

// i've also tried defining the string as @"\input.txt"
string fileloc = "\\input.txt"

while (!hasDoneStuff)
{
if (File.Exists(fileloc))
{
// do stuff
hasDoneStuff = true;
}
else
{
Thread.Sleep(5000);
}
}
==============================

The problem is, File.Exists returns "false" the first time through
(correctly, as the file isn't there yet) and causes an unhandled
native exception (which seems to elude my best try...catch) the
second.

Why won't File.Exists work at an interval? Is there something I'm
missing? If so, is there a creative workaround?

TIA,
Jake
 
J

Jake

Nobody else is having a problem with File.Exists? (Even when you
check for 2 different files where neither exist?) My app consistently
crashes the second time I check for a file and it doesn't exist... if
a file exists on the first try, I get one more check before it
crashes...
 
D

Duncan Mole

Jake, I am curious. Can you post a short piece of code that causes a crash?

Jake said:
Nobody else is having a problem with File.Exists? (Even when you
check for 2 different files where neither exist?) My app consistently
crashes the second time I check for a file and it doesn't exist... if
a file exists on the first try, I get one more check before it
crashes...

(e-mail address removed) (Jake) wrote in message
Sorry if this message repeats... I'm going to dumb this version down
to try to get a response more quickly, the last post I made doesn't
seem to have gotten here. I'm developing for a Pocket PC 2003 Phone
Edition.

For debugging purposes only, I'm using File.Exists in a loop with
Thread.Sleep. So it's something vaguely resembling:

[C#:]
==============================
bool hasDoneStuff = false;

// i've also tried defining the string as @"\input.txt"
string fileloc = "\\input.txt"

while (!hasDoneStuff)
{
if (File.Exists(fileloc))
{
// do stuff
hasDoneStuff = true;
}
else
{
Thread.Sleep(5000);
}
}
==============================

The problem is, File.Exists returns "false" the first time through
(correctly, as the file isn't there yet) and causes an unhandled
native exception (which seems to elude my best try...catch) the
second.

Why won't File.Exists work at an interval? Is there something I'm
missing? If so, is there a creative workaround?

TIA,
Jake
 
J

Jake

I just ran a simple test, and of course I can't reproduce the problem
outside of my app in development. But it's consistently a problem in
the app I'm working on.

I'm going to try recreating the Solution (how's THAT for a Solution?
;-]) using my existing code and, failing that, curl up into a ball and
cry. :-\

Thanks, and sorry for the multiple useless posts,

Jake
 
D

Duncan Mole

Hi Jake, hasDoneStuff in your actaul code wouldn't happen to be a property
of a control would it??

Jake said:
I just ran a simple test, and of course I can't reproduce the problem
outside of my app in development. But it's consistently a problem in
the app I'm working on.

I'm going to try recreating the Solution (how's THAT for a Solution?
;-]) using my existing code and, failing that, curl up into a ball and
cry. :-\

Thanks, and sorry for the multiple useless posts,

Jake

(e-mail address removed) (Jake) wrote in message
Sorry if this message repeats... I'm going to dumb this version down
to try to get a response more quickly, the last post I made doesn't
seem to have gotten here. I'm developing for a Pocket PC 2003 Phone
Edition.

For debugging purposes only, I'm using File.Exists in a loop with
Thread.Sleep. So it's something vaguely resembling:

[C#:]
==============================
bool hasDoneStuff = false;

// i've also tried defining the string as @"\input.txt"
string fileloc = "\\input.txt"

while (!hasDoneStuff)
{
if (File.Exists(fileloc))
{
// do stuff
hasDoneStuff = true;
}
else
{
Thread.Sleep(5000);
}
}
==============================

The problem is, File.Exists returns "false" the first time through
(correctly, as the file isn't there yet) and causes an unhandled
native exception (which seems to elude my best try...catch) the
second.

Why won't File.Exists work at an interval? Is there something I'm
missing? If so, is there a creative workaround?

TIA,
Jake
 
G

Guest

Hi Duncan,

No controls involved, this is a console app...

More information: (since my original and explanative post indeed did not
show up here)

We're developing a replacement for our old Motorola pagers, and we decided
to go with the Pocket PC 2003 Phone Edition. One of the snafus is that we
(as in: "unchangeable factor") have decided to keep using the old message
format as a transport, which means processing large numbers of emails (SMS
has been proven not to be ultimately reliable or affordable in our current
framework; we've opted for pulls rather than pushes).

I'm using InTheHand for database access and IP*Works! V6 for POP3
connectivity. I check an Exchange mailbox via POP3 at an interval plus
processing time (i.e. connect, download, and process emails, then
Thread.Sleep for one minute and do it all over again). This background app
is responsible for dumping information into the tables, which then get read
and the data displayed by a separate GUI app.

The console app portion is currently on the procedural side, as most of the
functionality runs in the static void Main method. My other utility methods
are private static, as well. The POP3 component is utilized from inside an
instantiated class created toward the beginning of the Main.

That's about all I can think to share for now. I'm working on getting a
code sample which is concise and reproducible; I'll post it ASAP.

Hopefully *something* I've said here will strike a chord with somebody and
there's an easy fix... I'll settle for a hard fix, at this point.
Unfortunately, almost all of my college programming experience was OO, and
most of my real-world coding has been procedural until recently, so I'm a
little rusty in what should and should not be...

As a side note, can anyone recommend some good Best Practices documents to
help me get into the swing of this better? There's a huge amount of
information on the subject, and I'm finding myself getting a bit lost in it
all...

Thanks,
Jake

Duncan Mole said:
Hi Jake, hasDoneStuff in your actaul code wouldn't happen to be a property
of a control would it??

Jake said:
I just ran a simple test, and of course I can't reproduce the problem
outside of my app in development. But it's consistently a problem in
the app I'm working on.

I'm going to try recreating the Solution (how's THAT for a Solution?
;-]) using my existing code and, failing that, curl up into a ball and
cry. :-\

Thanks, and sorry for the multiple useless posts,

Jake

(e-mail address removed) (Jake) wrote in message
Sorry if this message repeats... I'm going to dumb this version down
to try to get a response more quickly, the last post I made doesn't
seem to have gotten here. I'm developing for a Pocket PC 2003 Phone
Edition.

For debugging purposes only, I'm using File.Exists in a loop with
Thread.Sleep. So it's something vaguely resembling:

[C#:]
==============================
bool hasDoneStuff = false;

// i've also tried defining the string as @"\input.txt"
string fileloc = "\\input.txt"

while (!hasDoneStuff)
{
if (File.Exists(fileloc))
{
// do stuff
hasDoneStuff = true;
}
else
{
Thread.Sleep(5000);
}
}
==============================

The problem is, File.Exists returns "false" the first time through
(correctly, as the file isn't there yet) and causes an unhandled
native exception (which seems to elude my best try...catch) the
second.

Why won't File.Exists work at an interval? Is there something I'm
missing? If so, is there a creative workaround?

TIA,
Jake
 
G

Guest

I think I found the problem!

After blatant abuse of MessageBox.Show and many, many deploys, I was able to
track the problem down to my misuse of the InTheHand ADOCE component when
creating and altering tables via code.

After searching through their forums, I'm still not crystal clear on when or
how is the best time and method for flushing the connection (and if I need to
and am not)... but if I don't flush, I stop getting exceptions and my code
mysteriously begins working in full...

Thanks for trying to help!
Jake

Jake said:
Hi Duncan,

No controls involved, this is a console app...

More information: (since my original and explanative post indeed did not
show up here)

We're developing a replacement for our old Motorola pagers, and we decided
to go with the Pocket PC 2003 Phone Edition. One of the snafus is that we
(as in: "unchangeable factor") have decided to keep using the old message
format as a transport, which means processing large numbers of emails (SMS
has been proven not to be ultimately reliable or affordable in our current
framework; we've opted for pulls rather than pushes).

I'm using InTheHand for database access and IP*Works! V6 for POP3
connectivity. I check an Exchange mailbox via POP3 at an interval plus
processing time (i.e. connect, download, and process emails, then
Thread.Sleep for one minute and do it all over again). This background app
is responsible for dumping information into the tables, which then get read
and the data displayed by a separate GUI app.

The console app portion is currently on the procedural side, as most of the
functionality runs in the static void Main method. My other utility methods
are private static, as well. The POP3 component is utilized from inside an
instantiated class created toward the beginning of the Main.

That's about all I can think to share for now. I'm working on getting a
code sample which is concise and reproducible; I'll post it ASAP.

Hopefully *something* I've said here will strike a chord with somebody and
there's an easy fix... I'll settle for a hard fix, at this point.
Unfortunately, almost all of my college programming experience was OO, and
most of my real-world coding has been procedural until recently, so I'm a
little rusty in what should and should not be...

As a side note, can anyone recommend some good Best Practices documents to
help me get into the swing of this better? There's a huge amount of
information on the subject, and I'm finding myself getting a bit lost in it
all...

Thanks,
Jake

Duncan Mole said:
Hi Jake, hasDoneStuff in your actaul code wouldn't happen to be a property
of a control would it??

Jake said:
I just ran a simple test, and of course I can't reproduce the problem
outside of my app in development. But it's consistently a problem in
the app I'm working on.

I'm going to try recreating the Solution (how's THAT for a Solution?
;-]) using my existing code and, failing that, curl up into a ball and
cry. :-\

Thanks, and sorry for the multiple useless posts,

Jake

(e-mail address removed) (Jake) wrote in message
Sorry if this message repeats... I'm going to dumb this version down
to try to get a response more quickly, the last post I made doesn't
seem to have gotten here. I'm developing for a Pocket PC 2003 Phone
Edition.

For debugging purposes only, I'm using File.Exists in a loop with
Thread.Sleep. So it's something vaguely resembling:

[C#:]
==============================
bool hasDoneStuff = false;

// i've also tried defining the string as @"\input.txt"
string fileloc = "\\input.txt"

while (!hasDoneStuff)
{
if (File.Exists(fileloc))
{
// do stuff
hasDoneStuff = true;
}
else
{
Thread.Sleep(5000);
}
}
==============================

The problem is, File.Exists returns "false" the first time through
(correctly, as the file isn't there yet) and causes an unhandled
native exception (which seems to elude my best try...catch) the
second.

Why won't File.Exists work at an interval? Is there something I'm
missing? If so, is there a creative workaround?

TIA,
Jake
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top