using System;
using System.IO;
public class Exists
{
static public void Main (string [] args)
{
if (args.Length == 0)
{
Console.WriteLine ("Please enter a file name");
return;
}
if (!File.Exists (args[0]))
{
Console.WriteLine (args[0] + " does not exist");
return;
}
StreamReader reader;
try
{
reader = File.OpenText (args[0]);
}
catch (Exception e)
{
Console.WriteLine (e.Message);
Console.WriteLine ("Cannot open " + args[0]);
return;
}
while (reader.Peek() >= 0)
{
Console.WriteLine (reader.ReadLine ());
}
reader.Close ();
}
}
|