(300分送上)第三次提问 怎样查找得到某个共享文件夹内 所有文件(包括子文件夹)的所有文件名。

jiju 2002-05-12 12:20:17
包括http://www.csdn.net/expert/topic/667/667940.xml?temp=.8345911
和http://www.csdn.net/expert/topic/664/664885.xml?temp=.7644159
贴子的分一起送出.
给点例子吧。谢谢
...全文
36 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiju 2002-05-15
  • 打赏
  • 举报
回复
的确可以得到,但是如果有密码设置呢?:(
to: lvloj() ,: softwing(无人喝彩) 不知道就算了,希望你们去
http://www.csdn.net/expert/topic/667/667940.xml?temp=.8345911
和http://www.csdn.net/expert/topic/664/664885.xml?temp=.7644159
发一贴,我下次上网好给分。
谢谢你们的关心。。。
softwing 2002-05-12
  • 打赏
  • 举报
回复
将找到的文件名和目录名添加到Memo1中:
function AddFile(Directory:String):Boolean;
var
hFindFile: THandle;
Win32FD: TWin32FindData;
begin
Result := False;
Form1.Memo1.Clear;
if not SetCurrentDir(Directory) then
Exit;
hFindFile := FindFirstFile(PChar('*.*'), Win32FD);
if hFindFile <> INVALID_HANDLE_VALUE then
try
repeat
if Win32FD.dwFileAttributes <>FILE_ATTRIBUTE_DIRECTORY then
Form1.Memo1.Lines.Add('<文件>'+Win32FD.cFileName)
else
Form1.Memo1.Lines.Add('<目录>'+Win32FD.cFileName);
until not FindNextFile(hFindFile, Win32FD);
finally
Windows.FindClose(hFindFile);
end;
end;
lvloj 2002-05-12
  • 打赏
  • 举报
回复
procedure findall(disk,path: String; var fileresult: Tstrings);
var
fpath: String;
fs: TsearchRec;
begin
fpath:=disk+path+'\*.*';
if findfirst(fpath,faAnyFile,fs)=0 then
begin
if (fs.Name<>'.')and(fs.Name<>'..') then
if (fs.Attr and faDirectory)=faDirectory then
begin
fileresult.add(disk+path+'\'+fs.Name);
findall(disk,path+'\'+fs.Name,fileresult);
end
else
fileresult.add(disk+path+'\'+fs.Name);
while findnext(fs)=0 do
begin
if (fs.Name<>'.')and(fs.Name<>'..') then
if (fs.Attr and faDirectory)=faDirectory then
begin
fileresult.add(disk+path+'\'+fs.Name);
findall(disk,path+'\'+fs.Name,fileresult);
end
else
fileresult.add(disk+path+'\'+fs.Name);
end;
end;
findclose(fs);
end;

var
fileresult: TStringList;
begin
fileresult := TStringList.Create;
try
findall('\\hostname\shareName', '', fileresult);
……;//文件名保存在fileresult中。
finally
fileresult.free;
end;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧