Mega Code Archive

 
Categories / Delphi / Files
 

Bir klasörde rastgele isimle tek bir dosya ismi olusturmak

function CreateUniqueFileName(sPath: string): string; var chTemp: Char; begin repeat Randomize; repeat chTemp := Chr(Random(43) + 47); if Length(Result) = 8 then Result := Result + '.' else if chTemp in ['0'..'9', 'A'..'Z'] then Result := Result + chTemp; until Length(Result) = 12; until not FileExists(sPath + Result); end; // Kullanimi: procedure TForm1.Button1Click(Sender: TObject); begin label1.caption := CreateUniqueFileName('C:\temp\'); end;