-
-
Save rarous/5568310 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 hidden or 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