Click here to Skip to main content
15,899,825 members
Home / Discussions / C#
   

C#

 
GeneralRe: Invisible Winform Pin
Dave Kreskowiak7-May-09 14:22
mveDave Kreskowiak7-May-09 14:22 
GeneralRe: Invisible Winform Pin
jspoonermso7-May-09 14:57
jspoonermso7-May-09 14:57 
GeneralRe: Invisible Winform Pin
EliottA7-May-09 10:51
EliottA7-May-09 10:51 
GeneralRe: Invisible Winform Pin
jspoonermso7-May-09 11:45
jspoonermso7-May-09 11:45 
GeneralRe: Invisible Winform Pin
Big Daddy Farang7-May-09 12:00
Big Daddy Farang7-May-09 12:00 
AnswerRe: Invisible Winform Pin
jspoonermso7-May-09 12:31
jspoonermso7-May-09 12:31 
GeneralRe: Invisible Winform Pin
SimpleData10-May-09 6:11
SimpleData10-May-09 6:11 
QuestionAutorun checker and exception handling Pin
Rajdeep.NET is BACK7-May-09 9:49
Rajdeep.NET is BACK7-May-09 9:49 
Hello friends,

I have written this small piece of code to detect autorun.inf files, particularly in the C: and the D: drive:-

<br />
using System;<br />
using System.IO;<br />
class search<br />
{<br />
    public static void Main()<br />
    {<br />
        Console.WriteLine("Autorun checker");<br />
        if (File.Exists("C:/autorun.inf") || File.Exists("D:/autorun.inf"))<br />
        {<br />
            Console.WriteLine("Autorun Detected. Press Enter to delete it.");<br />
            Console.ReadLine();<br />
            File.Delete("C:/autorun.inf");<br />
            File.Delete("D:/autorun.inf");<br />
            Console.WriteLine("Autorun Deleted successfully.");<br />
            Console.ReadLine();<br />
        }<br />
        else<br />
        {<br />
            Console.WriteLine("No Autorun Detected. Press Enter to exit.");<br />
            Console.ReadLine();<br />
        }<br />
    }<br />
}<br />


Now, if no autorun files are detected in C:/ or D:/ drive, the program exits displaying "No Autorun Detected. Press Enter to Exit." But if detected, it successfully deletes that autorun file but throws a runtime exception. Suppose, it has detected an autorun.inf file in the C:/ drive, it will delete that file but throw some kind of exception like this:

File.Delete("D:/autorun.inf"); //Line marked as Error<br />
<br />
IOException was unhandled. The device is not ready


Can anyone help me out! I am new to .NET programming and dont posses that much knowledge about Exception handling.

Hope to hear from you guys soon,
Rajdeep.NET Big Grin | :-D
AnswerRe: Autorun checker and exception handling Pin
OriginalGriff7-May-09 10:11
mveOriginalGriff7-May-09 10:11 
GeneralRe: Autorun checker and exception handling Pin
Rajdeep.NET is BACK7-May-09 20:23
Rajdeep.NET is BACK7-May-09 20:23 
AnswerRe: Autorun checker and exception handling Pin
fly9047-May-09 10:19
fly9047-May-09 10:19 
AnswerRe: Autorun checker and exception handling Pin
Henry Minute7-May-09 10:27
Henry Minute7-May-09 10:27 
GeneralProbably in vain Pin
Luc Pattyn7-May-09 10:32
sitebuilderLuc Pattyn7-May-09 10:32 
QuestionAccepting user inputs in a console app. Pin
Rajdeep.NET is BACK7-May-09 9:18
Rajdeep.NET is BACK7-May-09 9:18 
AnswerRe: Accepting user inputs in a console app. Pin
Jimmanuel7-May-09 10:02
Jimmanuel7-May-09 10:02 
AnswerRe: Accepting user inputs in a console app. Pin
Dave Kreskowiak7-May-09 10:03
mveDave Kreskowiak7-May-09 10:03 
QuestionBackColor issue with main form and the controls Pin
Blubbo7-May-09 8:50
Blubbo7-May-09 8:50 
AnswerRe: BackColor issue with main form and the controls Pin
buachaill cliste7-May-09 9:17
buachaill cliste7-May-09 9:17 
GeneralRe: BackColor issue with main form and the controls Pin
Blubbo7-May-09 9:26
Blubbo7-May-09 9:26 
GeneralRe: BackColor issue with main form and the controls Pin
Henry Minute7-May-09 10:22
Henry Minute7-May-09 10:22 
AnswerRe: BackColor issue with main form and the controls Pin
Jabbar_espania8-May-09 1:51
Jabbar_espania8-May-09 1:51 
Question[Message Deleted] Pin
Ankit Aneja7-May-09 7:41
Ankit Aneja7-May-09 7:41 
AnswerRe: problem with datatype Pin
Dave Kreskowiak7-May-09 10:01
mveDave Kreskowiak7-May-09 10:01 
QuestionFramework 3.5 AccountManagement Pin
Jacob Dixon7-May-09 7:15
Jacob Dixon7-May-09 7:15 
QuestionHook on right button mouse Pin
teycir7-May-09 6:52
teycir7-May-09 6:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.