Verify File Exists

Discussion in 'ASP .Net' started by =?Utf-8?B?TXJNaWtl?=, Jan 5, 2005.

  1. This is a tough one, but here goes.

    I have a webform textbox where users input a filepath. For example:
    \\servername\sharename\file.xls. Is there anyway that I could use VB code to
    verify that the filepath and filename are valid after the user has input
    them? Basically this would serve to quality check whether or not the user
    has input the correct file path.

    Thanks.
     
    =?Utf-8?B?TXJNaWtl?=, Jan 5, 2005
    #1
    1. Advertising

  2. bool System.IO.File.Exists( string file )

    returns true or false if the file exists. The file parameter can be a UNC
    path, but you have to ensure you have read permissions to the directory.

    if System.IO.File.Exists( txtInput.Text ) = true Then
    'the file exists
    else
    'the file does not exist
    end if

    bill

    "MrMike" <> wrote in message
    news:...
    > This is a tough one, but here goes.
    >
    > I have a webform textbox where users input a filepath. For example:
    > \\servername\sharename\file.xls. Is there anyway that I could use VB code

    to
    > verify that the filepath and filename are valid after the user has input
    > them? Basically this would serve to quality check whether or not the user
    > has input the correct file path.
    >
    > Thanks.
     
    William F. Robertson, Jr., Jan 5, 2005
    #2
    1. Advertising

  3. Perfect! Thank you William!!!

    "William F. Robertson, Jr." wrote:

    > bool System.IO.File.Exists( string file )
    >
    > returns true or false if the file exists. The file parameter can be a UNC
    > path, but you have to ensure you have read permissions to the directory.
    >
    > if System.IO.File.Exists( txtInput.Text ) = true Then
    > 'the file exists
    > else
    > 'the file does not exist
    > end if
    >
    > bill
    >
    > "MrMike" <> wrote in message
    > news:...
    > > This is a tough one, but here goes.
    > >
    > > I have a webform textbox where users input a filepath. For example:
    > > \\servername\sharename\file.xls. Is there anyway that I could use VB code

    > to
    > > verify that the filepath and filename are valid after the user has input
    > > them? Basically this would serve to quality check whether or not the user
    > > has input the correct file path.
    > >
    > > Thanks.

    >
    >
    >
     
    =?Utf-8?B?TXJNaWtl?=, Jan 5, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlos Albert

    Verify if Session(hashtable) exists

    Carlos Albert, Dec 9, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    6,409
    addup
    Dec 14, 2005
  2. Jonny

    Verify that line exists in a file

    Jonny, Feb 19, 2005, in forum: C Programming
    Replies:
    9
    Views:
    381
    Mark McIntyre
    Feb 20, 2005
  3. Replies:
    4
    Views:
    1,026
  4. Henry Miranda

    Verify if file exists on network shared HELP

    Henry Miranda, Dec 17, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    120
    Henry Miranda
    Dec 17, 2003
  5. akadelski

    Verify URL/file exists

    akadelski, May 18, 2006, in forum: Javascript
    Replies:
    3
    Views:
    231
    Randy Webb
    May 19, 2006
Loading...

Share This Page