Link to home
Start Free TrialLog in
Avatar of infotechelg
infotechelgFlag for United States of America

asked on

Strange FTP Issue via .NET

I have C# code that FTP files. This has worked without issue since the code was written.

Recently, I was given a new server location to drop these files. The only code changes I made were the FTP location and the credentials. No other code changes were made.

Anyway, when I run the code, it executes with no errors. Everything appears to have worked. But when I use an FTP client to make sure the files made it on to the FTP server, there's nothing there.

I reached out to the FTP site owner to ask him to check his FTP's log files. He said he sees me connecting and doing a transfer, but there's no files in the transfer.

FWIW, when I try to FTP files via the client, there are no issues.

I'm at a loss considering this worked with the old FTP site, and that I've changed no code other than the credentials.

Any ideas?

Thanks in advance for your help.
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Did you recompiled the application under the same .Net Framework?
Avatar of infotechelg

ASKER

Yes
Can you post the section of code that you did change.
User generated image
The circled code is what changed. The first parameter is the IP address, the 2nd parameter the username, and the 3rd parameter the password.
The ftp class that you are using, is it a 3rd party code? if so who is the developer company?
I've attached the "upload" method from the "ftp" class. This code, however, has not been touched.User generated image
Hi infotechelg;

It looks good as you might of expected. The only thing I would try is to enable Network Tracing in your application and send to a file and see if you see anything that is not right. I have not done this in a while but there is a MS doc that explains it and can be found at Network Tracing in the .NET Framework Please give that a try. The line of code that will cause and that you want to see messages from is, reqStream.Write(data, 0, data.Length);.
ASKER CERTIFIED SOLUTION
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, it looks like the Upload method include a reference to "host" which is defined by a host IP (that is assigned when the ftp class is instantiated).  Are you passing the right host IP ?
Ugh. This ended up being very dumb. :) Dumb on my part. I got on TFS and looked at the old code. The "host" being passed in to the ftp instance was "ftp://ipaddress". When I changed the code, I got rid of the "ftp://" on accident. I didn't discover this until Megan asked if I had debugged the "upload" method. And duh...I hadn't. I put the "ftp://" back in with the new IP and it works.

It's Monday....

:)