Verify path is directory or file in C#

string path=@"C:\Desktop";
            
            if (System.IO.Directory.Exists(path))

             {
                 MessageBox.Show("Directory");

             }
              if(System.IO.File.Exists(path))
            {
                 MessageBox.Show("File");
            }
Next Recommended Reading Get am/pm from datetime in sql query