title: Xamarin Copy File Cross Platform
body: <p>Is it possible to copy a file in Xamarin Cross Platform? e.g. copy a SQLlite db3 from one directory to another. All i can get is the path of the file.</p>
  
  <p>I found solutions for Xamarain.Android and iOS but I want to have it combined in one Portable class.</p>
  
  <p><strong>EDIT</strong><br>
  Maybe there are better solutions out there but here is what I got with PCL Sotrage.</p>
  
  <pre><code>        IFile file = FileSystem.Current.GetFileFromPathAsync(src).Result;
          IFolder rootFolder = FileSystem.Current.GetFolderFromPathAsync(dest).Result;
          IFolder folder = rootFolder.CreateFolderAsync("MySubFolder", CreationCollisionOption.OpenIfExists).Result;
          IFile newFile = folder.CreateFileAsync("TodoItem.db3", CreationCollisionOption.GenerateUniqueName).Result;
  
          Stream str = file.OpenAsync(FileAccess.ReadAndWrite).Result;
          Stream newStr = newFile.OpenAsync(FileAccess.ReadAndWrite).Result;
  
          byte[] buffer = new byte[str.Length];
          int n;
          while ((n = str.Read(buffer, 0, buffer.Length)) != 0)
              newStr.Write(buffer, 0, n);
          str.Dispose();
          newStr.Dispose();
  </code></pre>