title: Upload video file to server with BackgroundUploader
body: <p>I am creating Windows store app targeting to <strong><em>Windows 8.0</em></strong><br>
  I have Windows 8.1 preview installed on my PC,I created app with VS2012 and implemented file uploading to server with <a href="http://msdn.microsoft.com/library/windows/apps/br207140" rel="nofollow">BackgroundUploader</a> and <a href="http://msdn.microsoft.com/en-US/library/windows/apps/windows.networking.backgroundtransfer.backgrounduploader.createuploadfromstreamasync" rel="nofollow">createUploadFromStreamAsync</a> method with the fallowing code - </p>
  
  <pre><code>string url = //url to upload videostring boundray = string.Format("abcboundry");
  String header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\n" + "Content-Type: {3}\r\n\r\n", boundray, "file", source.Name, "application/octet-stream");
  string footer = string.Format("\r\n--{0}--\r\n", boundray);
  
  Stream headerStream = GenerateStreamFromString(header);
  Stream footerStream = GenerateStreamFromString(footer);
  //Stream dataStream = iRandomstream.AsStream();
  Stream dataStream = await source.OpenStreamForReadAsync();
  
  MemoryStream fileDataStream = new MemoryStream();
  await headerStream.CopyToAsync(fileDataStream);
  await dataStream.CopyToAsync(fileDataStream);
  await footerStream.CopyToAsync(fileDataStream);
  fileDataStream.Position = 0;
  
  IInputStream stream = fileDataStream.AsInputStream();
  
  BackgroundUploader backgroundUploader = new BackgroundUploader();
  backgroundUploader.SetRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundray);
  backgroundUploader.Method = "POST";
  
  UploadOperation uploadOpration = await backgroundUploader.CreateUploadFromStreamAsync(new Uri(url), stream);
  
  await HandleUploadAsync(uploadOpration, true);
  </code></pre>
  
  <p>and it is working fine to me but when test on other system with Windows 8.0 installed app getting crash with <em>AccessViolationException was unhandled. Attempted to read or write protected memory. This is often an indication that other memory is corrupt." at the InitializeComponent.</em> error</p>
  
  <p>Now I tried to implenent <a href="http://msdn.microsoft.com/library/windows/apps/windows.networking.backgroundtransfer.backgroundtransfercontentpart.Aspx" rel="nofollow">BackgroundTransferContentPart</a> for multipart upload but not success with this code -</p>
  
  <pre><code>List&lt;BackgroundTransferContentPart&gt; parts = new List&lt;BackgroundTransferContentPart&gt;();
  BackgroundTransferContentPart part = new BackgroundTransferContentPart("file", source.Name);
  part.SetHeader("Content-Type", "application/octet-stream");
  part.SetFile(source);
  parts.Add(part);
  
  BackgroundUploader uploader = new BackgroundUploader();
  uploader.Method = "POST";
  UploadOperation uploadOp = await uploader.CreateUploadAsync(new Uri(url), parts, "form-data",boundray);
  
  await HandleUploadAsync(uploadOp, true);
  </code></pre>
  
  <p>What can I do to solve my problem ?</p>
  
  <p>How to Upload large file to server ?</p>