public static string SetDesktopImage(string arg) { if (arg.Contains("-h")) return SET_DESKTOP_IMAGE_COMMAND + " -u [image url] (-t [type])\nor\n" + SET_DESKTOP_IMAGE_COMMAND + " -f [image path] (-t [type])\n" + " the default type is 2 (streched)\n" + " types: 0 - Tiled; 1 - Centered"; string[] args = Program.argsConvertor(arg); string file_path = string.Empty; other.DesktopBackgroundChange.Style type; if (arg.Contains("-u")) { string uri = args[Array.IndexOf<string>(args, "-u") + 0x1].Replace('/', '\\'); string extension = uri.Split('\\')[uri.Split('\\').Length - 1]; System.IO.Stream s = new System.Net.WebClient().OpenRead(uri); System.Drawing.Image img = System.Drawing.Image.FromStream(s); string tempPath = IO.Path.Combine(IO.Path.GetTempPath(), "wallpaper." + extension); img.Save(tempPath); img.Dispose(); s.Close(); s.Dispose(); } else if (arg.Contains("-f")) file_path = args[Array.IndexOf<string>(args, "-f") + 0x1].Replace('/', '\\'); else return "bad filename"; if (arg.Contains("-t")) type = (other.DesktopBackgroundChange.Style)int.Parse(args[Array.IndexOf<string>(args, "-t") + 0x1]); else type = other.DesktopBackgroundChange.Style.Stretched; try { other.DesktopBackgroundChange.Set(file_path, type); return "ok!"; } catch (Exception ex) { return "error\n" + ex.ToString(); } }