944,081 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 4740
  • C# RSS
Mar 14th, 2005
0

errors make me close program

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
crypter is offline Offline
37 posts
since Jul 2004
Mar 14th, 2005
0

Re: errors make me close program

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).
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Mar 16th, 2005
0

Re: errors make me close program

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
Reputation Points: 10
Solved Threads: 0
Light Poster
crypter is offline Offline
37 posts
since Jul 2004
Mar 17th, 2005
0

Re: errors make me close program

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.
Reputation Points: 46
Solved Threads: 2
Junior Poster
Iron_Cross is offline Offline
117 posts
since Jul 2003
Mar 18th, 2005
0

Re: errors make me close program

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?
Reputation Points: 10
Solved Threads: 0
Light Poster
crypter is offline Offline
37 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Geometric Art using Triangles (C#)
Next Thread in C# Forum Timeline: On-the-fly string generation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC