• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Programmatic FTP using C# and Visual Studio 2008

Started by jswester, 2010.04.20, 19:12:46

Previous topic - Next topic

jswester

I am writing a text file parsing program in which I am attempting to FTP files from an FTP server setup on a remote Computer running OS2.  The default directory created in the FTP server setup is D:\rtiapps\log  and there are a number of files on this computer that use the convention filename.old.  It is these files I'm attempting to download.  I'm writing in C# using Visual Studio and the System.IO namespace.  The server does require credentials and I can successfully apply these and get logged into the FTP server.  I am using an FTPWebRequest object aand then sending credentials and setting the method to Download as seen in the code segment below:
            req2.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
            req2.Method = WebRequestMethods.Ftp.ListDirectory;
            req2.UsePassive = false;
            FtpWebResponse response = (FtpWebResponse)req2.GetResponse();
It is when I get to the response section that I get an error, "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)".  I know I'm getting logged in okay because I get a banner message of

"220 FTT111 IBM TCP/IP for OS/2 - FTP Server ver 09:39:01 on Mar 03 1995 ready.\r\n"

and a Welcome message:

"230 User LOG logged in.\r\n"  (the login is LOG with a password).

I also get a respones URI of:  {ftp://xx.xx.xx.xx/RTIAPPS/LOG}  (of course with the correct IP address in it).

I know this FTP server works because I can use a 3rd party tool to FTP successfully as well as successfully FPTing from an internet explorer window.  The status description by the way is as follows:

"550 D:\\RTIAPPS\\LOG/RTIAPPS/: error 2.\r\n"

This looks to me as if maybe it's not creating the path correctly (maybe interpreting backslashes corretly or something) but I've tried numerous variations and can't figure it out. 

Anybody used this FTP server before and maybe can see what I'm doing wrong here?  Thanks.

Javie Westerfield (Intel Corp) 





RobertM

#1
Hi Javie,

A few questions...

(1) is it possible to change from the default IBM FTPd to something like FTPd by Peter Moylan?

(2) have you tried changing into that directory? (ie: using the CWD FTP command) - and if so, what happens then?

(3) what are the values you are passing for directory and/or file information?

(4) what version of Visual Studio are you using? I do know that earlier Windows FTP client implementations had various bugs in them that did not work with various OS/2 and Linux FTP servers... perhaps there is where the issue lies (assuming you are using a very old version of the libraries).

More helpful information, which seems to indicate an incorrect usage (due to apparently a very un-intuitive method chosen by MS) of the C# request method is located here:
http://www.techtalkz.com/c-c-sharp/160335-how-change-directories-using-ftpwebrequest.html

You may find the answer at that link, as it seems others have run into similar problems. The solution used there was including:
request.KeepAlive = false
...after each request to reset the directory structure instead of appending it to the current request. I am guessing that would indicate that the C# libraries are not interpreting the initial slash as indicating "start at root of FTP tree" or some similar error/design flaw.

Best,
Robert


|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|


jswester

Robert,
Thanks for responding.  To answer your questions:
1) Unfortunately this computer is on a piece of industrial equipment whose configuration I can't change.
2) I did try some other commands but can't find a cwd method in this library.  Still playing with this though.
3)  I think somehow this is the root of the problem.  My URI is not setting, or interpreting the path to the files I'm trying to find.  Don't know why though as it seem to like the URI (it logs in just fine).
4)  I'm using Visual Studio Team System 2008 Architecture Edition.

I sitll think it's how my URI is being interpreted by the server so it's either in a strange directory or not in converting the slashes correctly.  Thanks for the link, I've found some sites that initially looked like they were having the exact same problem but the leads didn't get me anywhere.  This is a new one though so I'm keeping my fingers crossed.  Thanks again for looking at this.  I appreciate it.