By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,124 Members | 1,528 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,124 IT Pros & Developers. It's quick & easy.

FtpWebRequest

P: n/a
I need to access a FTP Server. I'm using FTPWebRequest as described in
visual studio 2005 documentation.
Everything works fine except the following:

1) I dont know how to change de current working directory on the server
to the parent directory?
2) Why cant I do this, or why doesn't work? In Internet explorer works!

<some code...for FtpWebRequest>

FtpWebRequest ....Create("ftp://192.168.1.4/../ret");
thanks
José Cruz

Dec 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
José,
In order to change directories you would need to be able to send the FTP
command for that, and I'm not sure if FTPWebRequest provides this
functionality.

See my answer to the "Simple FTP Request" post a few posts before yours
about the EnterpriseDT FTP.ENT library.

--Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"jo*************@gmail.com" wrote:
I need to access a FTP Server. I'm using FTPWebRequest as described in
visual studio 2005 documentation.
Everything works fine except the following:

1) I dont know how to change de current working directory on the server
to the parent directory?
2) Why cant I do this, or why doesn't work? In Internet explorer works!

<some code...for FtpWebRequest>

FtpWebRequest ....Create("ftp://192.168.1.4/../ret");
thanks
José Cruz

Dec 20 '05 #2

P: n/a
The FtpWebRequest class certainly does support this command.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:3C**********************************@microsof t.com...
José,
In order to change directories you would need to be able to send the FTP
command for that, and I'm not sure if FTPWebRequest provides this
functionality.

See my answer to the "Simple FTP Request" post a few posts before yours
about the EnterpriseDT FTP.ENT library.

--Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"jo*************@gmail.com" wrote:
I need to access a FTP Server. I'm using FTPWebRequest as described in
visual studio 2005 documentation.
Everything works fine except the following:

1) I dont know how to change de current working directory on the server
to the parent directory?
2) Why cant I do this, or why doesn't work? In Internet explorer works!

<some code...for FtpWebRequest>

FtpWebRequest ....Create("ftp://192.168.1.4/../ret");
thanks
José Cruz

Dec 21 '05 #3

P: n/a
Obvously I have not yet used this class in 2.0 or my answer would have been
more complete.

However, the Docs state as follows:

"Specify the FTP command to send to the server by setting the Method
property to a value defined in the WebRequestMethods.Ftp structure. To
transmit text data, change the UseBinary property from its default value
(true) to false. For details and restrictions, see Method."

I see the following methods listed in MSDN for the WebRequestMethods.Ftp
Members:

AppendFile Represents the FTP APPE protocol method that is used to append a
file to an existing file on an FTP server.
DeleteFile Represents the FTP DELE protocol method that is used to delete a
file on an FTP server.
DownloadFile Represents the FTP RETR protocol method that is used to
download a file from an FTP server.
GetDateTimestamp
GetFileSize Represents the FTP SIZE protocol method that is used to
retrieve the size of a file on an FTP server.
ListDirectory Represents the FTP NLIST protocol method that gets a short
listing of the files on an FTP server.
ListDirectoryDetails Represents the FTP LIST protocol method that gets a
detailed listing of the files on an FTP server.
MakeDirectory Represents the FTP MKD protocol method creates a directory on
an FTP server.
PrintWorkingDirectory Represents the FTP PWD protocol method that prints
the name of the current working directory.
RemoveDirectory Represents the FTP RMD protocol method that removes a
directory.
Rename Represents the FTP RENAME protocol method that renames a directory.
UploadFile Represents the FTP STOR protocol method that uploads a file to
an FTP server.
UploadFileWithUniqueName Represents

The above do not appear to include the "CD" command. If this is correct,
then the only way to actually get to a different folder on the remote FTP
Server would be to include it in the orignal request's login path.
--Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Spencer" wrote:
The FtpWebRequest class certainly does support this command.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:3C**********************************@microsof t.com...
José,
In order to change directories you would need to be able to send the FTP
command for that, and I'm not sure if FTPWebRequest provides this
functionality.

See my answer to the "Simple FTP Request" post a few posts before yours
about the EnterpriseDT FTP.ENT library.

--Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"jo*************@gmail.com" wrote:
I need to access a FTP Server. I'm using FTPWebRequest as described in
visual studio 2005 documentation.
Everything works fine except the following:

1) I dont know how to change de current working directory on the server
to the parent directory?
2) Why cant I do this, or why doesn't work? In Internet explorer works!

<some code...for FtpWebRequest>

FtpWebRequest ....Create("ftp://192.168.1.4/../ret");
thanks
José Cruz


Dec 21 '05 #4

P: n/a
And more (correcting myself as I go along, from MSDN):

"You can set Method to any command recognized by the server and use the
FtpWebRequest object to send the command. This works as expected only if the
command does not require you to send data and the server does not send data
in response to the request."

--Which indicates that you can send commands that arent in the enum. So, as
Kevin indicated, it appears that you can ( although it isn't blatantly
obvious) send the "CD" command with the FTPWebRequest class.

I leave it to the original poster to experiment and confirm this.

--Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Spencer" wrote:
The FtpWebRequest class certainly does support this command.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:3C**********************************@microsof t.com...
José,
In order to change directories you would need to be able to send the FTP
command for that, and I'm not sure if FTPWebRequest provides this
functionality.

See my answer to the "Simple FTP Request" post a few posts before yours
about the EnterpriseDT FTP.ENT library.

--Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"jo*************@gmail.com" wrote:
I need to access a FTP Server. I'm using FTPWebRequest as described in
visual studio 2005 documentation.
Everything works fine except the following:

1) I dont know how to change de current working directory on the server
to the parent directory?
2) Why cant I do this, or why doesn't work? In Internet explorer works!

<some code...for FtpWebRequest>

FtpWebRequest ....Create("ftp://192.168.1.4/../ret");
thanks
José Cruz


Dec 21 '05 #5

P: n/a
Hi Peter,

I hope I didn't come across as corrective towards you. I have used this
class, with this command, and I knew it can be used, and just wanted to make
sure the OP understood this. Your reponse was fine, as far as it went.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:3E**********************************@microsof t.com...
Obvously I have not yet used this class in 2.0 or my answer would have
been
more complete.

However, the Docs state as follows:

"Specify the FTP command to send to the server by setting the Method
property to a value defined in the WebRequestMethods.Ftp structure. To
transmit text data, change the UseBinary property from its default value
(true) to false. For details and restrictions, see Method."

I see the following methods listed in MSDN for the WebRequestMethods.Ftp
Members:

AppendFile Represents the FTP APPE protocol method that is used to append
a
file to an existing file on an FTP server.
DeleteFile Represents the FTP DELE protocol method that is used to delete
a
file on an FTP server.
DownloadFile Represents the FTP RETR protocol method that is used to
download a file from an FTP server.
GetDateTimestamp
GetFileSize Represents the FTP SIZE protocol method that is used to
retrieve the size of a file on an FTP server.
ListDirectory Represents the FTP NLIST protocol method that gets a short
listing of the files on an FTP server.
ListDirectoryDetails Represents the FTP LIST protocol method that gets a
detailed listing of the files on an FTP server.
MakeDirectory Represents the FTP MKD protocol method creates a directory
on
an FTP server.
PrintWorkingDirectory Represents the FTP PWD protocol method that prints
the name of the current working directory.
RemoveDirectory Represents the FTP RMD protocol method that removes a
directory.
Rename Represents the FTP RENAME protocol method that renames a directory.
UploadFile Represents the FTP STOR protocol method that uploads a file to
an FTP server.
UploadFileWithUniqueName Represents

The above do not appear to include the "CD" command. If this is correct,
then the only way to actually get to a different folder on the remote FTP
Server would be to include it in the orignal request's login path.
--Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Spencer" wrote:
The FtpWebRequest class certainly does support this command.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message
news:3C**********************************@microsof t.com...
> José,
> In order to change directories you would need to be able to send the
> FTP
> command for that, and I'm not sure if FTPWebRequest provides this
> functionality.
>
> See my answer to the "Simple FTP Request" post a few posts before yours
> about the EnterpriseDT FTP.ENT library.
>
> --Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "jo*************@gmail.com" wrote:
>
>> I need to access a FTP Server. I'm using FTPWebRequest as described in
>> visual studio 2005 documentation.
>> Everything works fine except the following:
>>
>> 1) I dont know how to change de current working directory on the
>> server
>> to the parent directory?
>> 2) Why cant I do this, or why doesn't work? In Internet explorer
>> works!
>>
>> <some code...for FtpWebRequest>
>>
>> FtpWebRequest ....Create("ftp://192.168.1.4/../ret");
>>
>>
>> thanks
>> José Cruz
>>
>>


Dec 21 '05 #6

P: n/a
Kevin,

No, not at all. Just trying to get the facts out, and as we all are finding
out, there are twice as many classes in 2.0 as were in 1.0!

I didn't see the command in the enum items listed in the MSDN Docs, and it
wasn't until I read further that you can construct any valid FTP Command in
that I realized you were correct.

I believe the OP had difficulty here since the "CD" command isn't listed as
one of the WebRequestMethods.Ftp members, you have to "create your own".

--Peter
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Spencer" wrote:
Hi Peter,

I hope I didn't come across as corrective towards you. I have used this
class, with this command, and I knew it can be used, and just wanted to make
sure the OP understood this. Your reponse was fine, as far as it went.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:3E**********************************@microsof t.com...
Obvously I have not yet used this class in 2.0 or my answer would have
been
more complete.

However, the Docs state as follows:

"Specify the FTP command to send to the server by setting the Method
property to a value defined in the WebRequestMethods.Ftp structure. To
transmit text data, change the UseBinary property from its default value
(true) to false. For details and restrictions, see Method."

I see the following methods listed in MSDN for the WebRequestMethods.Ftp
Members:

AppendFile Represents the FTP APPE protocol method that is used to append
a
file to an existing file on an FTP server.
DeleteFile Represents the FTP DELE protocol method that is used to delete
a
file on an FTP server.
DownloadFile Represents the FTP RETR protocol method that is used to
download a file from an FTP server.
GetDateTimestamp
GetFileSize Represents the FTP SIZE protocol method that is used to
retrieve the size of a file on an FTP server.
ListDirectory Represents the FTP NLIST protocol method that gets a short
listing of the files on an FTP server.
ListDirectoryDetails Represents the FTP LIST protocol method that gets a
detailed listing of the files on an FTP server.
MakeDirectory Represents the FTP MKD protocol method creates a directory
on
an FTP server.
PrintWorkingDirectory Represents the FTP PWD protocol method that prints
the name of the current working directory.
RemoveDirectory Represents the FTP RMD protocol method that removes a
directory.
Rename Represents the FTP RENAME protocol method that renames a directory.
UploadFile Represents the FTP STOR protocol method that uploads a file to
an FTP server.
UploadFileWithUniqueName Represents

The above do not appear to include the "CD" command. If this is correct,
then the only way to actually get to a different folder on the remote FTP
Server would be to include it in the orignal request's login path.
--Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Spencer" wrote:
The FtpWebRequest class certainly does support this command.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message
news:3C**********************************@microsof t.com...
> José,
> In order to change directories you would need to be able to send the
> FTP
> command for that, and I'm not sure if FTPWebRequest provides this
> functionality.
>
> See my answer to the "Simple FTP Request" post a few posts before yours
> about the EnterpriseDT FTP.ENT library.
>
> --Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "jo*************@gmail.com" wrote:
>
>> I need to access a FTP Server. I'm using FTPWebRequest as described in
>> visual studio 2005 documentation.
>> Everything works fine except the following:
>>
>> 1) I dont know how to change de current working directory on the
>> server
>> to the parent directory?
>> 2) Why cant I do this, or why doesn't work? In Internet explorer
>> works!
>>
>> <some code...for FtpWebRequest>
>>
>> FtpWebRequest ....Create("ftp://192.168.1.4/../ret");
>>
>>
>> thanks
>> José Cruz
>>
>>


Dec 21 '05 #7

P: n/a
Yes, I found the methodology of it somewhat confusing at first.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:FE**********************************@microsof t.com...
Kevin,

No, not at all. Just trying to get the facts out, and as we all are
finding
out, there are twice as many classes in 2.0 as were in 1.0!

I didn't see the command in the enum items listed in the MSDN Docs, and it
wasn't until I read further that you can construct any valid FTP Command
in
that I realized you were correct.

I believe the OP had difficulty here since the "CD" command isn't listed
as
one of the WebRequestMethods.Ftp members, you have to "create your own".

--Peter
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Spencer" wrote:
Hi Peter,

I hope I didn't come across as corrective towards you. I have used this
class, with this command, and I knew it can be used, and just wanted to
make
sure the OP understood this. Your reponse was fine, as far as it went.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message
news:3E**********************************@microsof t.com...
> Obvously I have not yet used this class in 2.0 or my answer would have
> been
> more complete.
>
> However, the Docs state as follows:
>
> "Specify the FTP command to send to the server by setting the Method
> property to a value defined in the WebRequestMethods.Ftp structure. To
> transmit text data, change the UseBinary property from its default
> value
> (true) to false. For details and restrictions, see Method."
>
> I see the following methods listed in MSDN for the
> WebRequestMethods.Ftp
> Members:
>
> AppendFile Represents the FTP APPE protocol method that is used to
> append
> a
> file to an existing file on an FTP server.
> DeleteFile Represents the FTP DELE protocol method that is used to
> delete
> a
> file on an FTP server.
> DownloadFile Represents the FTP RETR protocol method that is used to
> download a file from an FTP server.
> GetDateTimestamp
> GetFileSize Represents the FTP SIZE protocol method that is used to
> retrieve the size of a file on an FTP server.
> ListDirectory Represents the FTP NLIST protocol method that gets a
> short
> listing of the files on an FTP server.
> ListDirectoryDetails Represents the FTP LIST protocol method that gets
> a
> detailed listing of the files on an FTP server.
> MakeDirectory Represents the FTP MKD protocol method creates a
> directory
> on
> an FTP server.
> PrintWorkingDirectory Represents the FTP PWD protocol method that
> prints
> the name of the current working directory.
> RemoveDirectory Represents the FTP RMD protocol method that removes a
> directory.
> Rename Represents the FTP RENAME protocol method that renames a
> directory.
> UploadFile Represents the FTP STOR protocol method that uploads a file
> to
> an FTP server.
> UploadFileWithUniqueName Represents
>
> The above do not appear to include the "CD" command. If this is
> correct,
> then the only way to actually get to a different folder on the remote
> FTP
> Server would be to include it in the orignal request's login path.
> --Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "Kevin Spencer" wrote:
>
>> The FtpWebRequest class certainly does support this command.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> ..Net Developer
>> You can lead a fish to a bicycle,
>> but it takes a very long time,
>> and the bicycle has to *want* to change.
>>
>> "Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
>> message
>> news:3C**********************************@microsof t.com...
>> > José,
>> > In order to change directories you would need to be able to send the
>> > FTP
>> > command for that, and I'm not sure if FTPWebRequest provides this
>> > functionality.
>> >
>> > See my answer to the "Simple FTP Request" post a few posts before
>> > yours
>> > about the EnterpriseDT FTP.ENT library.
>> >
>> > --Peter
>> >
>> > --
>> > Co-founder, Eggheadcafe.com developer portal:
>> > http://www.eggheadcafe.com
>> > UnBlog:
>> > http://petesbloggerama.blogspot.com
>> >
>> >
>> >
>> >
>> > "jo*************@gmail.com" wrote:
>> >
>> >> I need to access a FTP Server. I'm using FTPWebRequest as described
>> >> in
>> >> visual studio 2005 documentation.
>> >> Everything works fine except the following:
>> >>
>> >> 1) I dont know how to change de current working directory on the
>> >> server
>> >> to the parent directory?
>> >> 2) Why cant I do this, or why doesn't work? In Internet explorer
>> >> works!
>> >>
>> >> <some code...for FtpWebRequest>
>> >>
>> >> FtpWebRequest ....Create("ftp://192.168.1.4/../ret");
>> >>
>> >>
>> >> thanks
>> >> José Cruz
>> >>
>> >>
>>
>>
>>


Dec 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.