Created
May 13, 2013 13:30
-
-
Save anonymous/5568302 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IStorage | |
{ | |
Uri Save(Stream data, string name); | |
Task<Stream> LoadAsync(Uri dataUri); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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