Ver Mensaje Individual
  #7  
Antiguo 22-11-2011
jonydread jonydread is offline
Miembro
NULL
 
Registrado: nov 2011
Posts: 157
Reputación: 15
jonydread Va por buen camino
Cita:
Empezado por escafandra Ver Mensaje
Hace varios meses publiqué una función para encontrar un nombre de archivo no repetido y proponer un nuevo nombre como lo hace Windows. La fuente es esta y el código este:

Código Delphi [-]
function FileNameOnCollision(FileName: String): String;
var
  FileExt: String;
  n: integer;
begin
  Result:= FileName;
  FileExt:= ExtractFileExt(FileName);
  SetLength(FileName, Length(FileName) - Length(FileExt));
  n:= 2;
  while FileExists(Result) do
  begin
    Result:= FileName + '(' + IntToStr(n) + ')' + FileExt;
    inc(n);
  end;
end;

Ejemplo de uso:
Código Delphi [-]
  Label1.Caption:= FileNameOnCollision(ExtractFilePath(Application.ExeName) + 'texto.txt');


Saludos.
Gracias! guardare la fuente!!
Responder Con Cita