Beispiel #1
0
            public static string HTTP_Download(string arg)
            {
                string[] args = Program.argsConvertor(arg);
                if (args.Length < 4) return "not enough arguments";

                string url = args[Array.IndexOf<string>(args, "-u") + 1];
                string destination = args[Array.IndexOf<string>(args, "-d") + 1];
                if (destination[0] == '\\')
                    destination = CurrentFolder.Substring(0, 2) + destination.Substring(1);
                else if (destination[1] != ':')
                    destination = CurrentFolder + destination;
                try
                {
                    using (System.Net.WebClient Client = new System.Net.WebClient())
                    {
                        Client.DownloadFile(url, destination);
                    }
                    return "downloaded to " + destination;
                }
                catch (Exception ex)
                {
                    return "error\n" + ex.GetType();
                }
            }