Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

tfilestream in a loop

filestream

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 Saeed7007

Saeed7007

    CC Regular

  • Member
  • PipPipPip
  • 43 posts

Posted 11 September 2015 - 09:14 AM

Hi

I wrote a program using tclientsocket for file ftransfer.

the client and server works fine for single file transfer but I get error for sending a list of file.

filestream overwrite at the second step of loop. I don;t know why

here is client code i changed:

-----------------------------------------------

procedure TClientForm.SendBTNClick(Sender: TObject);
var
   Buf : Pointer;
   i : integer;
begin
Timer1.Enabled := True;
 for I := 0 to Memo1.Lines.Count-1 do
  begin

  Application.ProcessMessages;
      fs := TFileStream.Create(Memo1.Lines[i], fmOpenRead OR
                                                fmShareDenyNone);

      GetMem(Buf, fs.Size);
      fs.Seek(0, soFromBeginning);

      fs.ReadBuffer(Buf^, fs.Size);

      MemoLog.Lines.Add('Has Send : ' +
                   IntToStr(ClientSocket1.Socket.SendBuf(Buf^, fs.Size)));
      FS.Free;

  end;
end;

------------------------------------------

memo1 :

c:\1.txt

c:\2.txt

c:\3.txt

 

It would be graet if tou could help me.

Thanks.



#2 Saeed7007

Saeed7007

    CC Regular

  • Member
  • PipPipPip
  • 43 posts

Posted 11 September 2015 - 11:22 PM

Any idea?



#3 Saeed7007

Saeed7007

    CC Regular

  • Member
  • PipPipPip
  • 43 posts

Posted 14 September 2015 - 03:00 AM

no one?