?
Solved

Problems handling text files with NMFTP and D6

Posted on 2003-03-02
5
Medium Priority
?
517 Views
Last Modified: 2010-04-04
Hello all :)
I do the following:

>> Create Application In Delphi 6
>> Use and setup NMFTP config (hosts/user/pass etc)
>> Set NMFTP file mode to MODE_ASCII
>> Successfully connect and download (GET) a text file from the host

now here's the problem, that text file i just downloaded, if i open it using notepad i can view it normally.
But if i open it in my own delphi application loading it
using a simple memo, rich edit or even using the Read() or EOF() fuctions it shows me crap (something like 'ÏùÔ').

And no its not my computer's problem (eg: not supported chars) because my D6 can read any other non-downloadable files. And another thing, even i that file i downloaded from NMFTP open it and save it inside notepad STILL D6
CANT read it... ok i'm going nuts here guys.

Could anyone explain why this happening and how to solve it?

Thanks in Advance!! :D

0
Comment
Question by:elissaios
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:mocarts
ID: 8056447
how do you download file? with NMFTP1.Download(filetoget, filetostore)?
I successfully downloaded my file and it correctly appears in my Memo1. with one exception OnSucces generates Trans_type = cmdUpload instead of cmdDownload :]

code I tested:
..
ftp: TNMFTP;
end;
..
procedure TForm1.Button1Click(Sender: TObject);
begin
  if Button1.Tag = 0 then begin
    ftp.Connect;
    Button1.Tag := 1;
    ftp.Mode(MODE_ASCII);
    ftp.changedir('files');
    Caption := ftp.CurrentDir;
    ftp.Download('jg.css', 'c:\jg.css');
  end else begin
    Button1.Tag := 0;
    ftp.Disconnect;
  end;
end;

procedure TForm1.ftpSuccess(Trans_Type: TCmdType);
begin
  if Trans_Type = cmdUpload then
    memo1.Lines.loadfromfile('C:\jg.css');
end;

connection made with authentication (UserID and password stored in dfm)
mo.
0
 

Author Comment

by:elissaios
ID: 8056532
hmmmmmm....

i used exactly the same method :)
the problem's still there...

i connect into my xbox console (yes it can happen since there's a ftp server CVS for it out there) and not in a regular unix/win server.

but i dont think thats the prob, i mean i can upload even
images on it and THEN download them from there and the're intact (valid).

i also noticed that the header of the file has 4 bytes more containing 2 special characters (i guess that for xbox file recognition). i could simply hex edit the file using some fuction before reading it.

but before doing that are there any other ideas/solutions out there? :\
0
 
LVL 9

Accepted Solution

by:
mocarts earned 600 total points
ID: 8056680
FF FE (or FE FF) - if you see theses bytes in the begining of your file, then you have deal with Unicode 16. UTF - 8 have 3 bytes in the begining of actual text (EF BB BF) and C4 before each extended (not ANSI) char.

check whether (and which exactly) your file have these encodings by clicking save as and looking in Save As dialog's encoding combobox.

wbr, mo.
0
 

Expert Comment

by:bkuyucu
ID: 8057853
I think u should not Set NMFTP file mode to MODE_ASCII,
rather Set NMFTP file mode to MODE_IMAGE that is binary mode. I tried and everything was fine.
Set
NMftp1.Mode(MODE_IMAGE);
before download.


0
 

Author Comment

by:elissaios
ID: 8325786
Thank you mo, this was the prob, thanks again :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month8 days, left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question