Ver Mensaje Individual
  #1  
Antiguo 15-04-2013
wolfran_hack wolfran_hack is offline
Miembro
 
Registrado: abr 2013
Posts: 97
Reputación: 14
wolfran_hack Va por buen camino
Problema a descargar actualización mediante WinInet

CODE:

Código Delphi [-]
function DescargarArchivo( sURL, sArchivoLocal: String ): boolean;
const BufferSize = 1024;
var
  hSession, hURL: HInternet;
  Buffer: array[1..BufferSize] of Byte;
  LongitudBuffer: DWORD;
  F: File;
  sMiPrograma: String;
begin
  sMiPrograma := ExtractFileName( Application.ExeName );
  hSession := InternetOpen( PChar( sMiPrograma ), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0 );

  try
    hURL := InternetOpenURL( hSession, PChar( sURL ), nil, 0, 0, 0 );

    try
      AssignFile( F, sArchivoLocal );
      Rewrite( F, 1 );

      repeat
        InternetReadFile( hURL, @Buffer, SizeOf( Buffer ), LongitudBuffer );
        BlockWrite( F, Buffer, LongitudBuffer ); //ERROR AQUI.
      until LongitudBuffer = 0;

      CloseFile( F );
      Result := True;
    finally
      InternetCloseHandle( hURL );
    end
  finally
    InternetCloseHandle( hSession );
  end
end;

Código Delphi [-]
procedure Form1.Button1Click(Sender: TObject);
begin
  DescargarArchivo( 'http:\\site.com\dni.csv', 'C:\dni.csv' );
end;

El archivo pesa 20Kb y me tirar error en el Buffer señalando esa linea y el texto:

Cita:
Project DNI.exe raised exception class EInOutError with message 'I/O error 1784'. Process stopped. Use Step or Run to continue.
Alguna idea?
Responder Con Cita