Skip to content

Instantly share code, notes, and snippets.

@LoriBru
Created January 14, 2019 14:27
Show Gist options
  • Select an option

  • Save LoriBru/82b0f0ba89b8f0aa48f84c4a6e073595 to your computer and use it in GitHub Desktop.

Select an option

Save LoriBru/82b0f0ba89b8f0aa48f84c4a6e073595 to your computer and use it in GitHub Desktop.
Snippet to copy a file from embedded assets to a folder.
using (var br = new BinaryReader(Application.Context.Assets.Open(FileName)))
{
using (var bw = new BinaryWriter(new FileStream("/Folder/" + $"{FileName}", FileMode.Create)))
{
var buffer = new byte[2048];
var length = 0;
while ((length = br.Read(buffer, 0, buffer.Length)) > 0)
{
bw.Write(buffer, 0, length);
}
}
}
new MediaScanner("/Folder/" + $"{FileName}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment