Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP import in pure code? 1

Status
Not open for further replies.

DanEvansJr

Programmer
Aug 17, 2001
41
0
0
US
I have an asp app that I'm writing that needs to perform some simple tasks. I'm basically trying to connect to our BULL mainframe via FTP and save a file in a location on the webserver. That SOUNDS simple enough, but everything that I've seen so far is pointing me to controls or pay-products. I'm thinking that's a bit of overkill. I need actual asp code. Not controls, or non-asp scripting languages.

Can anyone assist? In a desktop app, this is a few lines of code. This can't be that hard and I know I'm just missing something. I'm kinda new to the web world, so feel free to dumb it down for me.

Thanks in advance to anyone that can point me in the right direction.
 
I'm almost there! I found some code that apparently does what I need it to do, but . . . the file that I'm getting from the BULL location is coming over BINARY, and I need it as ASCII.

At this point I'm basically trying to show the returned results on a label. It works, but . . . Here's what I've got so far:


using System.Net;

//
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://<ipaddress>/testfile");
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential("<user>", "<pass>");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);

this.lblTestText.Text = reader.ReadToEnd();

reader.Close();
response.Close();
//


This is what I should be getting on the text for my lblTestText:
01 02 03 04
01 02 03 04
01 02 03 04
01 02 03 04
01 02 03 04
01 02 03 04
01 02 03 04
01 02 03 04


THIS is what I'm getting instead:
@`P???@01?h???@01?h???@01?h???@01?h???@01?h???@01?h???@01?h???@01?h??^1 ?C??@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?"???@ ?@ ?@ ?"?$?I!?J?Q<? "J?$? !??Y?W'?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ , ?q?@?G"??b ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?@ ?"??%B(?`1?F"??b1?@ ?@ ?@ ?@ ?%2@?@ ?@ ?Q??n8???@ ?@ ?@ ?@ ?@ ?@ ?@ , ?q ?#?@ ?@ ?@ ?@ ?@  ?E!???@ ?j6????`0?@ ?@ ?@ ?@ ?@ ?@ ?@ ?"?? ?q?@ ?@ ?@ ?@ ?@ ?@ ?yL?T ?B 0@ ?q??r1 ??@ ?@ ?@ ?@ ?@ ?@ ?@ , ?q?@ by@R???@ ?@ ?@ ?@ L?S(I?2(?@ ?@ q??X1 ????@ ?@ ?@ ?@ ?@ ?@ ?@ ?"???F '??2X?? ?@ ?@ ?@ ?@ %??@ ?@ ?@8?E?!??\0?@ ?@ ?@ ?@ ?@ ?@ ,
 
FOUND IT!

Turns out I need to explicitly tell the FtpWebRequest object (in my case, named 'request') to not use binary. The line of code is this:

request.UseBinary = false;
(this would come after the" request.Credentials" line

Works like it should!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top