By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

Program Crash with File IO Access

P: n/a
Hello,

I am running some code every 10 seconds to copy a file from a DOS server
over a Lantastic network. The problem is that when the DOS server is
restarted (it has to some times), my program crashes and reboots Windows. My
VB.Net Program is running on a Windows XP system using Lantastic 8.0 to
access the DOS server. How can I write the code so that if the DOS server
that the file is being copied from goes down, my VB.Net program continues to
run without crashing? Code is running in a timer control tick event and is
included below.

=========

Try

If File.Exists("\\Server1\Files\Data1.dbf") Then

Try
File.Copy(("\\Server1\Files\Data1.dbf",
"C:\Data\tblData.dbf", True)
Catch
'Do Nothing
End Try

End If

Catch

'Do Nothing

End Try
Nov 21 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Sarah,

The least thing you can do is changing in your code this

\\\
If File.Exists("\\Server1\Files\Data1.dbf") Then
Try
File.Copy(("\\Server1\Files\Data1.dbf",
"C:\Data\tblData.dbf", True)
Catch ex as exception
Messagebox.show(ex.tostring)
End Try
Else
messagebox.show("file does not exist)
End if
///

Making empty catch blocks is the worst thing you can do.

I hope this helps?

Cor

Nov 21 '05 #2

P: n/a

The least thing you can do is changing in your code this

\\\
If File.Exists("\\Server1\Files\Data1.dbf") Then
Try
File.Copy(("\\Server1\Files\Data1.dbf",
"C:\Data\tblData.dbf", True)
Catch ex as exception
Messagebox.show(ex.tostring)
End Try
Else
messagebox.show("file does not exist)
End if
///

Making empty catch blocks is the worst thing you can do.


Right now I have the Catch change the timer to a longer tick just to give it
some time before trying it again. I put the file.exists in a try/catch block
as well because I just can't stop the program from doing a full crash and
rebooting the system right away when the DOS server is restarted. The file
check/copy process is happening every 10 seconds so is there any other way
to do the check/copy so that it will not crash? Hope someone has some ideas.


Nov 21 '05 #3

P: n/a
Sarah,

Than maybe you have your problem directly. The catch is only slow the first
time it is used.

However you would surely not use that in my opinion for what you tell you
want to archieve.

I hope this helps?

Cor
Nov 21 '05 #4

P: n/a

Than maybe you have your problem directly. The catch is only slow the first time it is used.

What I said is when a try block enters a catch exception I have it so that
the timer tick does not check as frequently - i.e. not check every 10
seconds. That has nothing to do with the crash problem. You asked that a
catch exception should not be empty - which, I'm not sure should be a
problem - so, I mentioned what I have put there. (i.e. putting a msgbox in a
catch exception - that does not prevent the system from crashing).

I'm still looking for code that would not crash when the DOS server goes
down (i.e. is in a restart or is off).
However you would surely not use that in my opinion for what you tell you
want to archieve.

I hope this helps?

Cor

Nov 21 '05 #5

P: n/a
Sarah,
What I said is when a try block enters a catch exception I have it so that
the timer tick does not check as frequently - i.e. not check every 10
seconds. That has nothing to do with the crash problem. You asked that a
catch exception should not be empty - which, I'm not sure should be a
problem - so, I mentioned what I have put there. (i.e. putting a msgbox in
a
catch exception - that does not prevent the system from crashing).

What prevents it than?

Cor
Nov 21 '05 #6

P: n/a
That's my question! That's why I provided the code and am asking someone who
can help me figure it all out.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:#y**************@TK2MSFTNGP11.phx.gbl...

What prevents it than?

Cor

Nov 21 '05 #7

P: n/a
Sarah,
That's my question! That's why I provided the code and am asking someone
who
can help me figure it all out.

Therefore I wrote to set the messagebox in that catch, than is probably
better showed what gives the error.

The code you now have showed is something I would not even type in a message
so bad is it.
(The messagebox is only a timely part for a better error resolving
procedure)

Cor
Nov 21 '05 #8

P: n/a
Cor, please don't respond to any of my posts any more - you either always
seem to misunderstand my questions or post unhelpful comments. Thank you.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl...
Sarah,
That's my question! That's why I provided the code and am asking someone
who
can help me figure it all out.
Therefore I wrote to set the messagebox in that catch, than is probably
better showed what gives the error.

The code you now have showed is something I would not even type in a

message so bad is it.
(The messagebox is only a timely part for a better error resolving
procedure)

Cor

Nov 21 '05 #9

P: n/a
No problem at all, I hope for you that someone find a solution for you,
however mostly when I give a wrong answers someone else corrects me, what is
normal in a newsgroup.

I saw never corrections with your questions.

Cor


Nov 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.