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. how to check the files are exist or not in a floder

how to check the files are exist or not in a floder

Scheduled Pinned Locked Moved C#
csharphelptutorial
3 Posts 3 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.
  • R Offline
    R Offline
    ramyanaidu
    wrote on last edited by
    #1

    plz any ine help me i need a code for finding whether a file is exisisting in the folder if exist display the file woth some text or not create the file with some text and displaying message that file is created successfully using c#

    H A 2 Replies Last reply
    0
    • R ramyanaidu

      plz any ine help me i need a code for finding whether a file is exisisting in the folder if exist display the file woth some text or not create the file with some text and displaying message that file is created successfully using c#

      H Offline
      H Offline
      Hessam Jalali
      wrote on last edited by
      #2

      you can use System.IO.File.Exists(string path) method to check whether the file exists or not. good luck

      1 Reply Last reply
      0
      • R ramyanaidu

        plz any ine help me i need a code for finding whether a file is exisisting in the folder if exist display the file woth some text or not create the file with some text and displaying message that file is created successfully using c#

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        using System; using System.IO; using System.Collections; public class FileHandling { public static void Main(string[] args) { foreach(string path in args) { if(File.Exists(path)) { // Your code should run here } else if(Directory.Exists(path)) { //Your code should run here } else { Console.WriteLine("{0} is not a valid file or directory"); } } } Happy Programming ----- Abhijit

        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