Search code examples
c#wcfwcf-streaming

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


Solution

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