Page 1 of 1

If File Exists Method (C#)

Posted: Tue Mar 15, 2011 9:15 pm
by ieatlotz
I'm working on a dos style operating system. For this I'm using Cosmos.

I have a problem on my file manager, when I use the code:

Code: Select all

           using System;
           using System.IO;

            // See if this file exists from user input (whats typed)
            if (File.Exists(UserInput))
            {
                Console.WriteLine("The file exists.");
            }
I get the error:

Code: Select all

*** System Fault *** General Protection Fault at 0x005ADF6F
Does anyone know a solution to this problem?

Re: If File Exists Method (C#)

Posted: Tue Mar 15, 2011 9:51 pm
by Tosi
Maybe.

I have never programmed a line of C# before so expect this to be wrong.
Are you sure the File.Exists method is implemented, either by Cosmos or yourself? Is the implementation complete? Is there any line of code within that method that seems to be causing the fault?

Can you get more information about the General Protection Fault? What caused it, what were the values of the registers, a stack dump?

Re: If File Exists Method (C#)

Posted: Wed Mar 16, 2011 1:58 am
by Solar
Double-check that UserInput is of type System::String. Print it before calling File.Exists().

(I know that a mismatch should result in a compile-time error, but I don't know how faithfully the Cosmos environment and compiler handle this. I always recommend to assert the basic assumptions first.)