Skip to content

Instantly share code, notes, and snippets.

@rarous
Forked from anonymous/IStorage.cs
Created May 13, 2013 13:31
Show Gist options
  • Save rarous/5568310 to your computer and use it in GitHub Desktop.
Save rarous/5568310 to your computer and use it in GitHub Desktop.
public interface IStorage
{
Uri Save(Stream data, string name);
Task<Stream> LoadAsync(Uri dataUri);
}
public static class Storage
{
public static bool SaveDownloadedFile(WebResponse response, ref string fileName)
{
using (var stream = response.GetResponseStream())
{
if (stream == null)
return false;
using (var file = File.Create(fileName))
{
fileName = file.Name;
stream.CopyTo(file);
file.Close();
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment