Solved

How to Put NMFTP DirectoryList Items Inside a LIStView Control

Posted on 2002-07-02
8
1,026 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
[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
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
Technology Partners: 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!

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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