Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. check to see if a specified file exist in a specified directory

check to see if a specified file exist in a specified directory

Scheduled Pinned Locked Moved C#
question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pavya_Cool
    wrote on last edited by
    #1

    Hi to all, I want to check the specified file exist in the specified directory or not.... how can i do this?

    Pravin

    K N R 3 Replies Last reply
    0
    • P pavya_Cool

      Hi to all, I want to check the specified file exist in the specified directory or not.... how can i do this?

      Pravin

      K Offline
      K Offline
      Kuldeep Antil
      wrote on last edited by
      #2

      create the instance of FileInfo class //FileInfo f; initialze that in the following manner //f = new FileInfo("something.txt");///mention the complete path and then use this property to know whether this file exists or not ///if(f.Exists == false) /// means the file doesn't exist ok

      P 1 Reply Last reply
      0
      • K Kuldeep Antil

        create the instance of FileInfo class //FileInfo f; initialze that in the following manner //f = new FileInfo("something.txt");///mention the complete path and then use this property to know whether this file exists or not ///if(f.Exists == false) /// means the file doesn't exist ok

        P Offline
        P Offline
        pavya_Cool
        wrote on last edited by
        #3

        Thanks Kuldeep

        Pravin

        1 Reply Last reply
        0
        • P pavya_Cool

          Hi to all, I want to check the specified file exist in the specified directory or not.... how can i do this?

          Pravin

          N Offline
          N Offline
          Nissim Salomon
          wrote on last edited by
          #4

          Hi In order to check if a specific file exists You can use the File.Exists static method , you can also use the FileInfo.Exists property but for that you need to construct a FileInfo Object

          P 1 Reply Last reply
          0
          • N Nissim Salomon

            Hi In order to check if a specific file exists You can use the File.Exists static method , you can also use the FileInfo.Exists property but for that you need to construct a FileInfo Object

            P Offline
            P Offline
            pavya_Cool
            wrote on last edited by
            #5

            Thanks Nissims, i have used here object.FileExists(filespec) method.

            Pravin

            1 Reply Last reply
            0
            • P pavya_Cool

              Hi to all, I want to check the specified file exist in the specified directory or not.... how can i do this?

              Pravin

              R Offline
              R Offline
              ramdil
              wrote on last edited by
              #6

              You can directly check the path using if(System.IO.File.Exists(Path))

              Regards DilipRam

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups