Solved

How to handle an IO Exception in code because when the error "System.IO.IOException" occurs, the exe continues to run and the operator has to manually kill the process on the windows server?

Posted on 2016-09-26
1
57 Views
Last Modified: 2016-09-26
I created an exe from the attached source code (see attached B.TXT file). Do you know how I could revise this code to have the executable end gracefully when the following exception occurs?

Unhandled Exception: System.IO.IOException: The process cannot access the file because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
   at System.IO.File.Move(String sourceFileName, String destFileName)
   at ReadXML2.FileTest.ProcessFile(String filePathIn, String filePathOut1, String filePathOut2, String filePathOut3)
   at ReadXML2.FileTest.Main()
B.txt
0
Comment
Question by:zimmer9
1 Comment
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 41816171
try
{
  ProcessFile......
}
catch(Exception e)
{
  //add your code for failure here should you wish any
}
2

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now