Solved

How to Put NMFTP DirectoryList Items Inside a LIStView Control

Posted on 2002-07-02
8
975 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now