Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete file after end of streaming wcf

I uses netTcpBinding and streaming to send files from one server to another like described in this codeproject article,as I understand In wcf when we want to send stream we should create and return it as message contract, the question is how to get the finish of file sending? cause I want to move file from inbox to outbox when file sent guarantee completed

like image 585
Arsen Mkrtchyan Avatar asked Feb 27 '11 20:02

Arsen Mkrtchyan


2 Answers

I found great solution in this blog if someone will need it in the future

OperationContext clientContext = OperationContext.Current;
clientContext.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args)
   {
      if (fileStream != null)
         fileStream.Dispose();
   });
like image 97
Arsen Mkrtchyan Avatar answered Sep 22 '22 06:09

Arsen Mkrtchyan


When the second server has finished receiving the file from the first server, it could then call another web service method to acknowledge that it got the file. At that point, you can move the file from inbox to outbox with a guarantee that the other server received it.

like image 32
Saeed Avatar answered Sep 22 '22 06:09

Saeed