errors make me close program

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2004
Posts: 37
Reputation: crypter is an unknown quantity at this point 
Solved Threads: 0
crypter's Avatar
crypter crypter is offline Offline
Light Poster

errors make me close program

 
0
  #1
Mar 14th, 2005
Hey guys, i got this program im making. It encrypts and decrypts files. The problem is that whenever an error occurs while encrypting or decrypting ( having put a read-only file, a running program, input wrong keys, enter wrong encryption type...) the program tells me that an error occured. Thats nice and everything but i have to close the program, restart it and then try again. I can't just correct the mistake. If i do correct the mistake and try again, i get an error message again.

Basically i want to be able to correct mistakes without having to restart program. Does anyone know what to do?

It'll be great if someone can. Thanks in advance!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,752
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 740
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: errors make me close program

 
0
  #2
Mar 14th, 2005
To summarize, you want to know how to write a robust program. Unfortunately, that's an art that takes experience and practice. There aren't really any tricks to it. Just know what errors could possibly happen and write code to handle them gracefully (such as with try..catch blocks).
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 37
Reputation: crypter is an unknown quantity at this point 
Solved Threads: 0
crypter's Avatar
crypter crypter is offline Offline
Light Poster

Re: errors make me close program

 
0
  #3
Mar 16th, 2005
obviously everyone would want to create a perfect program, but you know it doesnt always work out to plan. ok concerning the try...catch blocks, i already got that. Whenever an error occurs in the process, it tells me! thats fine and great! BUT, if i try to do the process again, it gives an automatic error, even though the information it wants is correct! I have to close the program to be able to make it work.
i was wondering if there was some sort of code that involves a "dispose" code for an open file. I would like ti put that in the catch block
Reply With Quote Quick reply to this message  
Join Date: Jul 2003
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Solved Threads: 2
Iron_Cross's Avatar
Iron_Cross Iron_Cross is offline Offline
Junior Poster

Re: errors make me close program

 
0
  #4
Mar 17th, 2005
Just because it tells you there's an error doesn't mean your using try/catch block correctly. It will tell you there is an error even if you have any try/catch blocks. You need to try to handle the error in the try catch block.

From what you described, you need to reset the variables you're using inside the try/catch blocks or reset them when the encrypting is done (i.e. in a finally block). I'm like 99.99% sure that's what your problem is.
elitehackers.info
Today's Penny-Arcade!
Pain is weakness leaving the body!
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 37
Reputation: crypter is an unknown quantity at this point 
Solved Threads: 0
crypter's Avatar
crypter crypter is offline Offline
Light Poster

Re: errors make me close program

 
0
  #5
Mar 18th, 2005
i dont think you understand... i programmed it to tell me there is an error. But i don't know, like you say, handle the error.

would you know some sort of reset code?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC