473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Program Crash with File IO Access

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
9 1412
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

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
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

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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
Greetings, Having a major problem here. running version 8.2 on win2003 server. The problem I am having is backing up a database seems to get to the last part of the backup and then fails. This...
8
by: Adam Louis | last post by:
I would like help resolving this problem. I'm a novice who's been hired to query a hospital database and extract useful information, available to me only in a dynamically generated, downloadable...
14
by: JK Peck | last post by:
I have a fairly large Access application that ran correctly in Access 2000. After upgrading to Access 2003 (and recompiling and updating references), it reliably crashes at a certain point. If I...
7
by: Jamma | last post by:
Hello, I have an Access 2000 file working on XP machines and a NT network. The files are split and 95% of the time all is well and stable. The main issue arises when the app prints,a novell...
2
by: ray | last post by:
I have a client that doesn't want Access to automatically repair into a backup file if it crashes (and it crashes only on very rare occasions). My (sketchy) understanding is that this is a...
3
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
9
by: Keith G Hicks | last post by:
I'm having a lot of trouble with "file in use" errors in my "folder watcher" project. Starting and stopping the watcher and reading my XML file work fine. Once the watcher is started, I'm reading...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.