file path ?

3 отговора 146 прегледа
#1

file path ?

Kak da vzimam path-ovete na failove ot daden dir ?
na vsi4ki failove ...

Отговор
в отговор на az #2

Що за въпрос?????

След като файловете са в дадена директория - значи пътя до тях е един - мисля, че звучи логично а ?
Кажи какво точно се опитваш да направиш? Но ако обичаш с малко повече думи.

---
Отговор
в отговор на az #3

Re: file path ?

Returns the drive and directory portions of a file name.

Unit

SysUtils

Category

file name utilities

Delphi syntax:

function ExtractFilePath(const FileName: string): string;

----------------------------

Returns the current directory.

Unit

System

Category

file management routines

Delphi syntax:

procedure GetDir(D: Byte; var S: string);

Description

On Windows, GetDir sets the S parameter to the current directory on the drive specified by the D parameter. D can be set to any of the following values:

Value Drive

0 Default
1 A
2 B
3 C

------------------------------
I got a COMPILER, and I'm not afraid to use it!
Отговор
в отговор на az #4

Re: file path ?



unit FSearch;

interface
uses SysUtils, Classes;

function SearchFile( Path, FileName : string;
SubDir : boolean) : string;

function SearchFiles( Path, FileMask : string;
SubDir : boolean;
List : TStrings) : string;

implementation

function SearchFiles( Path, FileMask : string;
SubDir : boolean;
List : TStrings) : string;
var SR : TSearchRec;
begin
FindFirst(Path+'\*.*', faAnyFile, SR);
if SubDir and (SR.Attr and faDirectory > 0) then
begin
if (SR.Name <>'.') and (SR.Name <> '..') then
SearchFiles := SearchFiles(Path+'\'+SR.Name, FileMask, SubDir, List);
end
else if CompareFileName_Mask(SR.Name, FileMask) then
begin
List.Add(Path+'\'+SR.Name);
end;

while FindNext(SR) = 0 do
begin
if SubDir and (SR.Attr and faDirectory > 0) then
begin
if (SR.Name <>'.') and (SR.Name <> '..') then
SearchFiles := SearchFiles(Path+'\'+SR.Name, FileMask, SubDir, List);
end
else if CompareFileName_Mas(SR.Name, FileMask) then
begin
List.Add(Path+'\'+SR.Name);
end;
end;

end;

function SearchFile( Path, FileName : string;
SubDir : boolean) : string;
var SR : TSearchRec;
begin
FindFirst(Path+'\*.*', faAnyFile, SR);
if SubDir and (SR.Attr and faDirectory > 0) then
begin
if (SR.Name <>'.') and (SR.Name <> '..') then
SearchFile := SearchFile(Path+'\'+SR.Name, FileName, SubDir);
end
else if UpperCase(SR.Name) = UpperCase(FileName) then
begin
Result := Path+'\'+SR.Name;
FindClose(SR);
Exit;
end;

while FindNext(SR) = 0 do
begin
if SubDir and (SR.Attr and faDirectory > 0) then
begin
if (SR.Name <>'.') and (SR.Name <> '..') then
SearchFile := SearchFile(Path+'\'+SR.Name, FileName, SubDir);
end
else if UpperCase(SR.Name) = UpperCase(FileName) then
begin
Result := Path+'\'+SR.Name;
FindClose(SR);
Exit;
end;
end;
end;

end.



Никога не е късно човек да се провали!
Отговор