I am working on an issue I do not remember ever having before. I am using VS2012 C#
When i add using System.IO
; to my main program everything works fine
You need to put it inside a function or sub, property and so forth.
You need to put the code in a method, for example:
class FoxySearch
{
public bool DoesFileExist(string filePath)
{
return File.Exists(filePath);
}
}
You use File.Exists() in class not in method it is a problem.
You must add Reference to assembly in your project.
You haven't really given enough code to say for sure, but it sounds like you're probably trying to write "normal code" directly in a class declaration, instead of in a method or property declaration.
Classes can only include declarations - method declarations, field declarations etc. You can't write:
class Foo
{
int i = 10;
Console.WriteLine(i);
}
etc. The first line is valid as it's a variable declaration - the second isn't, as it's just a method call. If you move the code into a method, then it's fine:
class Foo
{
public void Bar()
{
int i = 10;
Console.WriteLine(i);
}
}
Additionally, I'd suggest that you revisit your naming - using the same name for a class and a namespace is a bad idea.
u have written in class, u cant write there. & also file.Exists() returns boolean value. u have to write something like this:
boolean a= File.Exists("bla");