Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Delphi - Problema Download Immagini Server\Client
Forum - Delphi - Problema Download Immagini Server\Client

Avatar
DragoHacker (Normal User)
Newbie


Messaggi: 8
Iscritto: 08/10/2011

Segnala al moderatore
Postato alle 15:45
Sabato, 08/10/2011
Ragazzi ho un problema con questo codice per ricevere immagini

Codice sorgente - presumibilmente Delphi

  1. var
  2.   iLen: Integer;
  3.   Bfr: Pointer;
  4.   Text : string;
  5.   F: File of byte;
  6. NumRead: Integer;
  7. Buffer: array [1..8196] of Char;
  8. begin
  9.   if not ReceivingFile then
  10.   begin
  11.    Text := Socket.ReceiveText;
  12.     if Copy(Text, 1, 5) = 'SIZE!' then
  13.     begin
  14.       Delete(Text, 1, 5);
  15.       Len := StrToInt(Text);
  16.       ProgressBar2.Max := StrToInt(Text);
  17.       FStream := TFileStream.Create('schermo.jpg', fmCreate or fmShareDenyWrite);
  18.       ReceivingFile := true;
  19.     end;
  20.   end
  21.   else
  22.   begin
  23.     iLen := Socket.ReceiveLength;
  24.     GetMem(Bfr, iLen);
  25.     try
  26.       Socket.ReceiveBuf(Bfr^, iLen);
  27.       FStream.Write(Bfr^, iLen);
  28.       Progressbar2.Position := ProgressBar2.Position + iLen;
  29.       if progressbar2.Position = 100 then begin
  30.       progressbar2.Position := 0;
  31.       end;
  32.     finally
  33.        FreeMem(Bfr);
  34.        if Assigned(FStream) and (FStream.Size = Len) then
  35.        begin
  36.          FStream.Free;
  37.          FStream := nil;
  38.          ReceivingFile := true;
  39.        end;
  40.     end;
  41.   end;
  42. end;



Praticamente quando scarico l'immagine dal pc remoto e il download è completo l'immagine non si apre perchè dice che è usata da un altro processo, potete dirmi come posso risolvere? Grazie in anticipo

PM
Avatar
GN (Member)
Guru


Messaggi: 772
Iscritto: 30/04/2011

Up
1
Down
V
Segnala al moderatore
Postato alle 20:09
Sabato, 08/10/2011
Non so niente di Delphi ma ho avuto problemi simili con "file usato da un altro processo"; posso consigliarti di far aspettare un secondo all'applicazione (immagino che anche in Delphi ci sia qualcosa come Timer o Thread.Wait()) in modo che il tentavo di apertura avvenga quando il download è sicuramente terminato.

PM