C# Console Application - How to scan if a specific folder or text file exist? RRS feed

  • Question

  • I wanted to know if it's possible to scan if a specific folder or a specific text file actually exist in a specified folder path?

    For example- If I write "123" than it scans the folder path I gave for any folder named "123" or scans for a text file named "123".

    If it's possible please help me and let me know. Thank you!

    Saturday, April 28, 2018 12:46 PM


  • Try:

    if(System.IO.Directory.Exists("dirPath")) {// Do sth.;}


    if (System.IO.File.Exists("filePath")) {// Do sth.;} 


    • Edited by Wizend Saturday, April 28, 2018 1:07 PM edit
    • Marked as answer by yuvalmus Saturday, April 28, 2018 2:18 PM
    Saturday, April 28, 2018 1:05 PM