Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50752

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

Upvotes: 5

Views: 2313

Answers (2)

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50752

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();
   });

Upvotes: 5

Saeed
Saeed

Reputation: 307

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.

Upvotes: 2

Related Questions