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");
            }