Created
October 30, 2018 11:41
-
-
Save hkucuk/a13ec8c9545da93b60ce080ac9ef6ea7 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
class Program | |
{ | |
private static T Deserialize(string objStr) | |
{ | |
byte[] b = Convert.FromBase64String(objStr); | |
using (var stream = new MemoryStream(b)) | |
{ | |
var formatter = new BinaryFormatter(); | |
stream.Seek(0, SeekOrigin.Begin); | |
return (T)formatter.Deserialize(stream); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
string strArg = args[0]; | |
var arg = Deserialize(strArg); | |
for (int i = 0; i <= arg.UrlList.Count; i++) | |
{ | |
var uri = new Uri(arg.UrlList[i]); | |
var localFileName = System.IO.Path.GetFileName(uri.LocalPath); | |
try | |
{ | |
WebClient webClient = new WebClient(); | |
webClient.DownloadFile(uri, localFileName); | |
Console.WriteLine(localFileName + "...ok"); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(localFileName + "...err" + ex.Message); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment