There are quite a few things you need to look at here, but the compilation error you are probably getting relates to the line:
File fe = (new Directory(".")).GetFiles(cmdline);
And tells you that you can't create an array of static objects.
The problem is that the File class is static - there is one and only one instance of it for the entire application, so you cannot under any circumstances create a File variable, and certainly not an array of them - because you can't get at the object to fill it with!
Butthere is a wider problem with this line: GetFiles is a static property of the Directory class, and it doesn't return File objects, it returns an array of strings. So what you actually should have said here is:
string fe = Directory.GetFiles(cmdline);
But that isn't actually what you want to do either! There is a much, much easier way to achieve what you want:
Console.WriteLine(cmdline + ": file not found");
}"sir can u edit the above code and update it please using if(!File.Exists(loadFille)"
Well...it's your homework...so I really shouldn't...
But, ok - if you can tell me exactly what is going on, and why I moved some of your code around!
public static void Main(string args)
String cmdline = Environment.GetCommandLineArgs();
Console.WriteLine("File Reader Using Stream Reader & File Stream \n");
if (cmdline.Length < 2)
Console.WriteLine("Usage: " + cmdline + " <input file> ");
string loadFile = cmdline;
Console.WriteLine(loadFile + " : file not found");
FileRead fr = new FileRead();
FileInfo fi = new FileInfo(loadFile);
fr.ReadFile(loadFile, (int) fi.Length);
catch (IOException e)
Console.WriteLine("I/O error occured" + e);