掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
TIdFTPについて (ID:15990)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
またまた 時間がないので 手抜きですけど、 PCのファイルだけ列挙します。 空のフォルダは列挙しませんので自分で改良してみてください ExtractFilePath() ExtractFileName() をつかうと簡単に分離します FTP操作があっちこっちフォルダして複雑にならないように ファイル名は ソートしておくようにしておきました。 あとFTPサーバー側を フォルダ移動して、 適当にファイル名をおいていくだけです。 はりつけて遊ぶと ファイル名取得の雰囲気だけわかると思います(^_^) unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); private { Private 宣言 } public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.dfm} function GetFileList(Path : string; Kaikensaku:boolean) : TStringList; var SList : TStringList; procedure GetFileNames(Path : string); var sr: TSearchRec; FileAttrs: Integer; FindResult : Integer; begin FileAttrs := faAnyFile - faVolumeID; FindResult := FindFirst(Path+'*.*', FileAttrs, sr); try while (FindResult = 0) do begin if (sr.Name = '.') or (sr.Name = '..') then begin FindResult := FindNext(sr); Continue; end; if (sr.Attr and faDirectory) > 0 then begin if Kaikensaku then GetFileNames(Path+sr.Name+'\'); end else SList.Add(Path+sr.Name); FindResult := FindNext(sr); end; finally FindClose(sr); end; end; begin if Not IsPathDelimiter(Path,Length(Path)) then Path := Path + '\'; SList := TStringList.Create; SList.Sorted := True; SList.Duplicates := dupIgnore; if DirectoryExists(Path) then GetFileNames(Path); Result := SList; end; procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Lines := GetFileList('c:\windows\temp',true); // Memoなどのコンポーネントに代入しない場合は、Freeすること end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.