473,804 Members | 3,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FTPWebRequest and CD

Could someone show me how to use the FtpWebRequest and change to a different
directory? Changing directories is not listed as one of the methods, but I
believe it can be done--just can't figure out how.
Feb 17 '07 #1
6 9462
The methos is:

ftpObject.ChDir (m_sRemotePath)

I just did this for a recent project - it works great. The remote path
is without the \ at the end.

T
William LaMartin wrote:
Could someone show me how to use the FtpWebRequest and change to a different
directory? Changing directories is not listed as one of the methods, but I
believe it can be done--just can't figure out how.
Feb 17 '07 #2

"William LaMartin" <la******@tampa bay.rr.comwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Could someone show me how to use the FtpWebRequest and change to a
different directory? Changing directories is not listed as one of the
methods, but I believe it can be done--just can't figure out how.
I spent last week downloading a dozen or so examples using ftpwebrequest and
NONE of them worked as downloaded.

I am trying to find out how to use ftpwebrequest.K eepAlive property. The
documentation says
"When the KeepAlive property is set to false, the control connection is
closed when you call the Close method."

BUT there is no accessable close method for ftpwebrequest.

It took me a week to discover that instances of ftpwebrequest can not be
created.

Demilitarized code? Pardon the metaphor.

Respectfully Richard,


Feb 19 '07 #3

"William LaMartin" <la******@tampa bay.rr.comwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Could someone show me how to use the FtpWebRequest and change to a
different directory? Changing directories is not listed as one of the
methods, but I believe it can be done--just can't figure out how.
I think I might have found what I have been looking for the
ftpwebrequest.m ethod accepts a "string" value.

I have not tried the standard ftp commands i.e. cd (change directory),
close, etc.

ftpwebrequest.m ethod ="cd"

Richard
Feb 20 '07 #4
>
ftpwebrequest.m ethod ="cd"
The above does not work either.

Have to parse the path name with the directory path then create a new
"ftpwebrequest" . AFAIK

Richard
Feb 20 '07 #5
On Feb 16, 11:50 pm, "William LaMartin" <lamar...@tampa bay.rr.com>
wrote:
Could someone show me how to use the FtpWebRequest and change to a different
directory? Changing directories is not listed as one of the methods, but I
believe it can be done--just can't figure out how.
you cannot use the command directly, but you can modify the uri
parameter to achieve the same result.

Let's say you're using the following format:

String uri = "ftp://myFtpUserName:m yFtpUserPasswor d@myFtpUrl";

FtpWebRequest Request = (FtpWebRequest) WebRequest.Crea te(uri);

Request.Method = "LIST";

The above example will bring you to your user's directory and list all
the contents there. Now let's say you want to go 2 directories
backwards and list the contents there (provided your user has
permissions to do that). You close the previous FtpWebRequest and
issue a new one with this uri

uri = "ftp://myFtpUserName:m yFtpUserPasswor d@myFtpUrl/%2E%2E/%2E%2E";

This is equivalent to logging in with your user's credentials and then
using cd ../../

Note: if you try using the ".." directly without escaping them the
uri class will strip them, so "ftp://
myFtpUserName:m yFtpUserPasswor d@myFtpUrl/../.." is equivalent to
"ftp://myFtpUserName:m yFtpUserPasswor d@myFtpUrl/"

Now let's say you want to go to another user's directory which is one
level above the root. If you don't specify a user name and password
it's equivalent to logging in as anonymous user. Then you issue a new
FtpWebRequest with the following uri

"ftp://myFtpUrl/%2F/anotherUserDir"

This is equivalent to logging in as anonymous and then doing

Cd /

cd anotherUserDire ctory

Feb 20 '07 #6
Then you issue a new
FtpWebRequest with the following uri

"ftp://myFtpUrl/%2F/anotherUserDir"

This is equivalent to logging in as anonymous and then doing

Cd /

cd anotherUserDire ctory
I understand.

I was hoping there was a way to keep the connection alive between requests.
Like a telnet connection.
The FtpWebRequest class comes with a value "FtpWebRequest. KeepAlive" but it
does not seem to do anything.

I can think of no reason for keeping the connection alive except when
sending passwords in the clear would require sending the password only once
versus every access.

Without spending money for accurate documentation this problem could lead to
be a big waste of time

Thanks,
Richard
Feb 20 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3573
by: Kevin Spencer | last post by:
Hi all, I am working on a service that uploads METAR weather information to the National Weather Service FTP site. The service I'm authoring is hosted on a Windows 200 server, and the NWS FTP host is on a Unix server. I'm using the FtpWebRequest and FtpWebResponse classes to do the file uploading. I have tested it without any errors at all uploading to an IIS FTP server hosted on our network Most of the time it uploads without error to...
7
16223
by: jose.lopes.cruz | last post by:
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>
0
2773
by: Alexis | last post by:
Hello, I am trying to upload a file to an ftp server using the FtpWebRequest class, but I get the following error. The requested URI is invalid for this FTP command. I do can upload the file from the Internet Explorer so I have rights to do it. Why is the 2.0 FtpWebRequest class failing? What I am doing wrong? My Code:
2
10336
by: Ian Hannah | last post by:
I am running the following code (using VS 2005) with the appropriate username and password and the request always timeouts: FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://integration300:20/"); request.Method = WebRequestMethods.Ftp.ListDirectory; request.UsePassive = false; request.Credentials = new NetworkCredential(<user>,<password>); request.Proxy = null;
3
9719
by: Kevien Lee | last post by:
hi everyone I have a quick question when i use the FtpWebRequest. What I need to do is that: Connect a FTP server,check whether there is a folder if not,create it, then changed the path to the new folder If use the command line to do that,it just use the "CD" command can finish.But there is not the command in WebRequestMethods.Ftp
0
9803
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
5
7696
by: Sendil kumar | last post by:
Hi All, The FtpWebRequest.GetResponse( ) method is not giving "550 File not found exception " when I do a directory list operation on a invalid(not present) directory in HP Unix and Sun Solaris system, but the same is working fine in windows. For example, this is my uri to connect to the Sun Solaris server machine "ftp://ssriniva:ssriniva@apfsun/apfqa/users/ssriniva/apfhome/config" here the 'config' folder is not present in the...
9
3903
by: Waldy | last post by:
Hi there, I have written a service in VS2005 that downloads files from an FTP site processes them and then deletes the files if successfully processed. It all works fine when run in our test lab with an FTP site that I setup on IIS. However, I have an issue at the customer site. Their FTP server is on Linux, but I presume that is not an issue. What happened the first time I ran it was that it deleted every other file. It just so...
6
13694
by: Patrick.Simons | last post by:
I try to connect a FTPWebRequest through Proxy and VPN to a remote FTP- server. Sometimes it works sometimes not. When my VB.Net-App (2005) returns the error on the GetResponse-Method, I'll try to use the Windows Explorer to go on the FTP-URI and this always works. So the problem should come from my app. my simplified code: Private m_oFTP As FtpWebRequest Private oResponseDir As FtpWebResponse = Nothing
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.