istnienie katalogu

0

jak sprawdzić czy istnieje katalog? wiem że z plikiem związana jest procedura if FileExists()... ale co z katalogami??? prosze o szybką odp.. :(

0
DirectoryExists('c:\Qpa');
0

nie wiem czemu ale to nie jest poprawne polecenie chyba.. wywala błąd przy kompilcaji.. a może musze dodać coś do uses'ów? :(

0
if directoryexists('c:\windows') then showmessage('Jest folder') else showmessage('Gdzies wcielo folder');
0

DirectoryExists jest w SysUtils

0

Czy tak trudno naciśnąć F1 i sprawdzić? Help nie gryzie. A znajomość angielskiego wymagana do przeczytania tego tekstu znikoma.

Determines whether a specified directory exists.

Unit

FileCtrl

Category

file management routines

function DirectoryExists(Name: string): Boolean;

Description

Call DirectoryExists to determine whether the directory specified by the Name parameter exists. If the directory exists, the function returns True. If the directory does not exist, the function returns False.

If a full path name is entered, DirectoryExists searches for the directory along the designated path. Otherwise, the Name parameter is interpreted as a relative path name from the current directory.

[dopisek]

Ale chodzi o to samo. Chciałbym zauważyć, ze posiadam Delphi 5.

0

Chyba się Szymek odrobinkę pomyliłeś. Nie ten unit

Unit

SysUtils

Category

file management routines

Delphi syntax:

function DirectoryExists(const Directory: string): Boolean;

C++ syntax:

extern PACKAGE bool __fastcall DirectoryExists(const AnsiString Directory);

Description

Call DirectoryExists to determine whether the directory specified by the Name parameter exists. If the directory exists, the function returns true. If the directory does not exist, the function returns false.

If a full path name is entered, DirectoryExists searches for the directory along the designated path. Otherwise, the Name parameter is interpreted as a relative path name from the current directory.

The FileCtrl unit (Windows only) also contains a DirectoryExists function. However, the FileCtrl version is deprecated, and the SysUtils version preferred, even if the code does not need to be cross-platform.

Inna sprawa, że akurat w tym wypadku składnia i opis są identyczne w obu unitach. Ale tak nie jest zawsze, ponadto zamieszałeś pytającemu co do unita.

0

The FileCtrl unit (Windows only) also contains a DirectoryExists function. However, the FileCtrl version is deprecated, and the SysUtils version preferred, even if the code does not need to be cross-platform.

  • hehe, fragment FileCtrl:
function DirectoryExists(const Name: string): Boolean;
begin
  Result := SysUtils.DirectoryExists(Name);
end;
0
Uses Windows;

Function DirectoryExists(const FileName: string):Boolean;
Var FD:TWin32FindData;
      H:THandle;
Begin
 H:= ;-) FindFirstFile(PCHAR(FileName),FD);
 If (FD.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY<>0) and (H<>INVALID_HANDLE_VALUE) then
 Begin
  Result:=True;
  FindClose(H);
 End else Result:=False;
End;

1 użytkowników online, w tym zalogowanych: 0, gości: 1