Results 1 to 5 of 5

Thread: [RESOLVED] File exist?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Resolved [RESOLVED] File exist?

    What code do I use to check if a file exists, and to check that the file is not a blank file (e.g. 0kb in size)?

    Cheers

  2. #2
    Frenzied Member ntg's Avatar
    Join Date
    Sep 2004
    Posts
    1,449

    Re: File exist?

    Use System.IO.File.Exists() and System.IO.FileInfo.
    "Feel the force...read the source..."
    Utilities: POPFileDebugViewProcess ExplorerWiresharkKeePassUltraVNCPic2Ascii
    .Net tools & open source: DotNetNukelog4NetCLRProfiler
    My open source projects: Thales SimulatorEFT CalculatorSystem Info ReporterVSS2SVNIBAN Functions
    Customer quote: "If the server has a RAID array, why should we bother with backups?"
    Programmer quote: "I never comment my code. Something that is hard to write should be impossible to comprehend."
    Ignorant quote: "I have no respect for universities, as they teach not practicle stuff, and charge money for"

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: [RESOLVED] File exist?

    Perfect

  4. #4
    Member
    Join Date
    Apr 2004
    Posts
    59

    Re: [RESOLVED] File exist?

    you could do something like this

    VB Code:
    1. If System.IO.File.Exists("c:\doc1.doc") Then
    2.             System.IO.File.Delete("c:\doc1.doc"))
    3.         End If
    That will check if c:\doc1.doc exists, if it does, it will delete it.


    This might also be useful to you:

    VB Code:
    1. If Not (System.IO.Directory.Exists("c:\somefolder")) Then
    2.             System.IO.Directory.CreateDirectory("c:\somefolder").Attributes = FileAttributes.Hidden
    3.         End If
    this checkes if a directory exists, if it does not, it creates it!

  5. #5
    Member
    Join Date
    Apr 2004
    Posts
    59

    Re: [RESOLVED] File exist?

    Oops, I think I was a little too late!

Posting Permissions

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



Click Here to Expand Forum to Full Width