Check the Existance of a Directory

image_pdfimage_print
   
 


using System;
using System.IO;

class MainClass {
    static void Main(string[] args) {
        foreach (string arg in args) {
            Console.Write(arg);

            if (Directory.Exists(arg)) {
                Console.WriteLine(" is a  directory");
            } else if (File.Exists(arg)) {
                Console.WriteLine(" is a  file");
            } else {
                Console.WriteLine(" does not exist");
            }
        }
    }
}

           
         
     


This entry was posted in File Stream. Bookmark the permalink.