title: Cannot create STREAM from file or string
body: <p>I am trying to create a stream from a file or a string but I am getting the below error.</p>
  
  <pre><code>ReadTimeout = 'stream.ReadTimeout' threw an exception of type 'System.InvalidOperationException'
  WriteTimeout = 'stream.WriteTimeout' threw an exception of type 'System.InvalidOperationException'
  </code></pre>
  
  <p>I found a sample code to create a stream. It seems fine but it gives the error above</p>
  
  <p>By the way, I am trying to send data to Amazon MWS Feed Api. Here is my full code below.</p>
  
  <pre><code>using (Stream s = GenerateStreamFromString("D:\\feed.xml"))
  {
        SubmitFeedRequest request = new SubmitFeedRequest();
        request.Merchant = merchantId;
        request.MarketplaceIdList = new IdList();
        request.MarketplaceIdList.Id = new List&lt;string&gt;(new string[] { marketplaceId });
        request.FeedContent = s;
        request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent);
        //request.FeedContent.Position = 0;
  
        request.FeedType = "_POST_INVENTORY_AVAILABILITY_DATA_";
  
        SubmitFeedSample.InvokeSubmitFeed(service, request);
    }
  
  
   public static Stream GenerateStreamFromString(string s)
   {
       MemoryStream stream = new MemoryStream();
       StreamWriter writer = new StreamWriter(stream);
       writer.Write(s);
       writer.Flush();
       stream.Position = 0;
       return stream;
   }
  </code></pre>
  
  <p>What am I doing wrong? I have read many forums but I dont understand.</p>
  
  <p>It gives the error seen in the image below </p>
  
  <p><a href="https://i.stack.imgur.com/CPbau.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CPbau.png" alt="enter image description here"></a></p>