Closed Thread
Results 1 to 5 of 5

Thread: Check if a File Exists

  1. #1
    NeedHelp Guest

    Check if a File Exists

    Is there a function in C# to tell if a file exists or not?

    I was viewing this thread:
    Check if a file exists

    and it came across me that I didn't know of a function to do this in C#.

  2. CODECALL Circuit advertisement

     
  3. #2
    hoser2001's Avatar
    hoser2001 is offline Programmer
    Join Date
    Jul 2006
    Posts
    175
    Rep Power
    0
    you need to use the system.IO library

    using System.IO;

    string filename = @"filepath"
    if (filename.exists)
    {
    some code
    }

  4. #3
    Jordan Guest
    Quote Originally Posted by hoser2001
    you need to use the system.IO library

    using System.IO;

    string filename = @"filepath"
    if (filename.exists)
    {
    some code
    }
    It would be

    Code:
    if (File.Exists(filename)) {
    }

    http://msdn2.microsoft.com/en-us/lib...le.exists.aspx

  5. #4
    hoser2001's Avatar
    hoser2001 is offline Programmer
    Join Date
    Jul 2006
    Posts
    175
    Rep Power
    0
    Jordan!

    Thank you very much for correcting me. Sorry for the mishap.

  6. #5
    Ronin is offline Programming Professional
    Join Date
    Apr 2006
    Posts
    309
    Rep Power
    24
    I do that all the time. I'll be thinking one thing and type another. You could tell that was what you meant to type. lol

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Check if multiple remote files exists HELP! (Using curl)
    By SeanStar in forum PHP Development
    Replies: 7
    Last Post: 12-17-2010, 09:06 AM
  2. Linux/Bash: Check if a file exists
    By Tor in forum Bash / Shell Scripting
    Replies: 4
    Last Post: 07-10-2009, 11:28 AM
  3. Check if a file exists?
    By Lop in forum Pascal and Delphi
    Replies: 3
    Last Post: 01-06-2007, 10:54 PM
  4. Check if a file exists
    By Lop in forum C and C++
    Replies: 4
    Last Post: 08-07-2006, 08:03 PM
  5. Check if a URL Exists
    By Chan in forum PHP Development
    Replies: 1
    Last Post: 07-13-2006, 10:54 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts