PDA

Click to See Complete Forum and Search --> : Ftp


Techno
Dec 4th, 2005, 02:00 PM
Hi there.

using .NET 2.0 here and C# :D

I am trying to use the FTP stuff in the Framework but have a couple of Questions....

Fair enough, when we request the directory (ListDirectory) we see all the files and folders. Cool! But, if we wish to navigate to a selected folder, how do we do this?

Currently I am thinking that we need to pretty much re-establish a connection BUT add the name of the directory infront of the FTP URL, surely there must be another way because I can think of a few disadvantages of doing it this way...

As well as this, is there a way to see what type the folder/file it is? (if the current selected "text" is a file/folder?)

I would be appreciated if someone can give me an answer to my first question if possible, the 2nd one is not as important.

Thank-you :)

deranged
Dec 4th, 2005, 06:56 PM
http://cr.yp.to/ftp.html

yere ya go. read up a bit on the protocol.

Techno
Dec 4th, 2005, 07:04 PM
lol im sorry but thats not helpful. I KNOW about the FTP protocol but wanting to know how to actually do this in .NET

currently im just making a new FtpWebRequest object everytime I wish to perform a command. So pretty much if i wish to navigate to a selected folder, I've done this....

BUT how can I see if the selected item is a folder/file? I always get an exception stating that the remote server returned an error (550) - File unavailable. But the file DOES exist as if i change the method to "ListDirectory"... it works fine but of course not doing what I want to do... get the file size or just to check to see what type of item it is that has been selected

im doing this:


FtpWebRequest temp = (FtpWebRequest)WebRequest.Create(this.listRequest.RequestUri + "/" + selectedItem);
temp.Method = WebRequestMethods.Ftp.GetFileSize;
temp.Credentials = new NetworkCredential(this.txtUsername.Text, this.txtPassword.Text);

FtpWebResponse theFTPObjectResponse = (FtpWebResponse)temp.GetResponse(); //HERE
this.reader = new StreamReader(temp.GetResponse().GetResponseStream());