Parse FTP url

Discussion in 'ASP .Net' started by MarkusJNZ@gmail.com, Sep 7, 2006.

  1. Guest

    Hi all, does anyone know how I can parse an ftp url to retrieve the
    server, login and password?

    e.g. given a ftp url like

    ftp://ftplogin:

    I can get out the following info

    server = subdomain.domain.com
    password = mypass
    login = ftplogin

    I can successfully get the url etc by doing string parsing etc but I
    would like a better way which is not open to interpretation.

    e.g. Someone might have a @ or a : in their password then the string
    parsing may run into problems.

    TIA
    Markus

    =================================
    jhgklioplsjdujehhrejhjrejhekdsdlkasdlerksdksd
     
    , Sep 7, 2006
    #1
    1. Advertising

  2. Hi Markus,

    You want to see if the members of the Uri class can parse this for you:

    http://msdn2.microsoft.com/en-us/library/system.uri_members.aspx

    I notice UserInfo pulls out the username and password:

    http://msdn2.microsoft.com/en-us/library/system.uri.userinfo.aspx

    See also

    UriSchemeFtp

    http://msdn2.microsoft.com/en-us/library/system.uri.urischemeftp.aspx

    <> wrote in message
    news:...
    > Hi all, does anyone know how I can parse an ftp url to retrieve the
    > server, login and password?
    >
    > e.g. given a ftp url like
    >
    > ftp://ftplogin:
    >
    > I can get out the following info
    >
    > server = subdomain.domain.com
    > password = mypass
    > login = ftplogin
    >
    > I can successfully get the url etc by doing string parsing etc but I
    > would like a better way which is not open to interpretation.
    >
    > e.g. Someone might have a @ or a : in their password then the string
    > parsing may run into problems.
    >
    > TIA
    > Markus
    >
    > =================================
    > jhgklioplsjdujehhrejhjrejhekdsdlkasdlerksdksd
    >
     
    Ken Cox [Microsoft MVP], Sep 7, 2006
    #2
    1. Advertising

  3. re:
    > I notice UserInfo pulls out the username and password:


    Yes, UserInfo pulls them out.
    Then, with GetComponents, you can get the host server's name:

    Sub Page_Load()
    Dim uriAddress As New Uri("ftp://ftplogin:/")
    Label1.Text = uriAddress.UserInfo
    Label2.Text = uriAddress.GetComponents(UriComponents.Host, UriFormat.Unescaped)
    End Sub

    See an example running at : http://asp.net.do/test/UriComponents.aspx





    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en espaƱol : http://asp.net.do/foros/
    ===================================

    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > Hi Markus,
    >
    > You want to see if the members of the Uri class can parse this for you:
    >
    > http://msdn2.microsoft.com/en-us/library/system.uri_members.aspx
    >
    > I notice UserInfo pulls out the username and password:
    >
    > http://msdn2.microsoft.com/en-us/library/system.uri.userinfo.aspx
    >
    > See also
    >
    > UriSchemeFtp
    >
    > http://msdn2.microsoft.com/en-us/library/system.uri.urischemeftp.aspx
    >
    > <> wrote in message news:...
    >> Hi all, does anyone know how I can parse an ftp url to retrieve the
    >> server, login and password?
    >>
    >> e.g. given a ftp url like
    >>
    >> ftp://ftplogin:
    >>
    >> I can get out the following info
    >>
    >> server = subdomain.domain.com
    >> password = mypass
    >> login = ftplogin
    >>
    >> I can successfully get the url etc by doing string parsing etc but I
    >> would like a better way which is not open to interpretation.
    >>
    >> e.g. Someone might have a @ or a : in their password then the string
    >> parsing may run into problems.
    >>
    >> TIA
    >> Markus
    >>
    >> =================================
    >> jhgklioplsjdujehhrejhjrejhekdsdlkasdlerksdksd
    >>

    >
    >
     
    Juan T. Llibre, Sep 7, 2006
    #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. someone

    FTP over SSL vs FTP over SSH

    someone, Apr 24, 2004, in forum: Java
    Replies:
    1
    Views:
    4,637
    iksrazal
    Apr 25, 2004
  2. Replies:
    3
    Views:
    5,747
  3. Nico Grubert
    Replies:
    0
    Views:
    674
    Nico Grubert
    Nov 24, 2005
  4. Nico Grubert
    Replies:
    0
    Views:
    467
    Nico Grubert
    Nov 25, 2005
  5. D. Buck
    Replies:
    2
    Views:
    564
    D. Buck
    Jun 29, 2004
Loading...

Share This Page