Solved

How to Put NMFTP DirectoryList Items Inside a LIStView Control

Posted on 2002-07-02
8
999 Views
Last Modified: 2012-05-04
Hi there,

How can I put the values of NMFTP Directory List inside a Listview Control?

I Was able to put NMFTP Directory List Values in a listbox but the thing is, I have to parse it to get specific information like, date, attributes, size, filename, etc.

I kNow NMFTP Directory list passes the values as a string parameter when the List Method is invoked but how do you get the attribute, name, size, etc from the string parameter?

I tried testing this to get the attribute of a certain file on the list but:

showmessage(NMFTP1.FtpDirectOryList.Attribute.Text);

but it returns a blank box.

Any help would be greatly appreciated.
0
Comment
Question by:lapuk
8 Comments
 
LVL 7

Expert Comment

by:Cynna
ID: 7125050
lapuk,

> showmessage(NMFTP1.FtpDirectOryList.Attribute.Text);

should be:

showmessage(NMFTP1.FTPDirectoryList.Attribute.Strings[index]);

(for example, index=0, will get you attribute string of first file)

Few remarks:

1. Using List method does not guarantee you to parse atribute, name, size... correctly. This depends on directory listings formatting of the FTP server you are connecting to. If this happens, probably the best would be setting ParseList to false and then using the OnListItem event to do your own manual parsing.

2. NM... (NetMasters) components are known to be quite buggy. I'd advise you to forget them all together, and use third party components (like ICS or Indy).
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7125647
> 1. Using List method does not guarantee you to parse atribute, name, size... correctly.  
that's so true !! in fact in my testing it didn't parse a single site correctly !!!

as Cynna I suggest you to use Indy from www.nevrona.com/indy
0
 

Author Comment

by:lapuk
ID: 7125875
I tried this :
showmessage(NMFTP1.FTPDirectoryList.Attribute.Strings[index]);

but it gives me an out of bounds error, I just wonder why when in fact it was able to list the values inside a listbox..
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Accepted Solution

by:
Cynna earned 100 total points
ID: 7126494
lapuk,

Here's comlete example that works (most of the time: read my remark #2 in previous post, and then read it again).
Initially Copy/Paste it, to see if it works for your local/remote system:

(place Button and NMFTP on the form)

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin
  NMFTP1.ParseList := True;
  NMFTP1.Vendor := NMOS_AUTO;
  NMFTP1.Connect;
  while not NMFTP1.Connected do begin
     Application.ProcessMessages;
     Sleep(1);
  end;
  Memo1.Lines.Clear;
  Memo1.Lines.Add('Connected');
  NMFTP1.List;
  for i := 0 to NMFTP1.FTPDirectoryList.Name.Count - 1 do
      Memo1.Lines.Add(Format('File: %s, Size: %s, Date: %s, Attr: %s', [
                     NMFTP1.FTPDirectoryList.Name[i],
                     NMFTP1.FTPDirectoryList.Size[i],
                     NMFTP1.FTPDirectoryList.ModifDate[i],
                     NMFTP1.FTPDirectoryList.Attribute[i]]));
  NMFTP1.Disconnect;
end;
0
 

Expert Comment

by:CleanupPing
ID: 9343119
lapuk:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Author Comment

by:lapuk
ID: 9345235
Hi sorry all, it took me quite a while to respond to this, thanks to everyone who excerted the effort in finding a solution to my problem. Although this question has been raised a long time ago, and fortunately, I found my own way of solving it.

My solution is almost the same as that of Cynna, although a used Tstringlist instead. My FTP server returns a directory list but all attributes are in a single line, so I have to make a parseing routine to be able to assign specific attributes for each record.

So I am accepting Cynnas Answer instead. :-)

Thanks everyone.
0
 

Author Comment

by:lapuk
ID: 9345251
Hmm.. weird.. I am trying to accept cynnas answer but it gives me this message..

 " You cannot accept this answer.. " hmnn.. kinda weird.
0
 

Author Comment

by:lapuk
ID: 9345256
oh.. ok.. now its updated :-)

Thanks all!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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