title: Sharing violation on path in xamarin
body: <p>I'm very new to Android programming.  I have a code which creates a file in a designated folder and then tried to write something to it. Like below:  </p>
  
  <pre><code>        path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
          var filename = Path.Combine(path, "Test.xml");
          Directory.CreateDirectory (path);
          if (!File.Exists (path + "/" + "Test.xml")) {
              File.Create (path + "/" + "Test.xml");
          }
          using (var streamWriter = new StreamWriter(filename, true))
          {
              streamWriter.WriteLine("&lt;?xml version='1.0' encoding='utf-8'?&gt;");
              streamWriter.WriteLine ("&lt;Apples&gt;");
              streamWriter.WriteLine ("&lt;/Apples&gt;");
          }
  </code></pre>
  
  <p>In line <strong>using (var streamWriter = new StreamWriter(filename, true))</strong>, I'm getting the <strong>Sharing Violation on path</strong> error.</p>
  
  <p>Could someone please point me as to exactly where I'm going wrong and provide me a solution.</p>
  
  <p>Thanks,
  Anirban</p>