Home All Groups Group Topic Archive Search About
Author
7 Sep 2006 2:51 AM
MarkusJNZ
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:myp***@subdomain.domain.com

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

Author
7 Sep 2006 3:51 AM
Ken Cox [Microsoft MVP]
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

<Markus***@gmail.com> wrote in message
Show quoteHide quote
news:1157597487.390331.81230@i3g2000cwc.googlegroups.com...
> 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:myp***@subdomain.domain.com
>
> 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
>
Are all your drivers up to date? click for free checkup

Author
7 Sep 2006 2:32 PM
Juan T. Llibre
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:myp***@subdomain.domain.com/")
    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/
===================================

Show quoteHide quote
"Ken Cox [Microsoft MVP]" <BANSPAMkjopc@newsgroups.nospam> wrote in message
news:enaKrDj0GHA.4116@TK2MSFTNGP02.phx.gbl...
> 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
>
> <Markus***@gmail.com> wrote in message news:1157597487.390331.81230@i3g2000cwc.googlegroups.com...
>> 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:myp***@subdomain.domain.com
>>
>> 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
>>
>
>

Bookmark and Share