예제 #1
0
            public static void DownloadFile(int fi)
            {
                try
                {
                    Configs.File file = InvalidFiles[fi];

                    _fileIndex = fi;

                    if (file.Name.Contains(@"\"))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(file.Name));
                    }

                    WebClient webClient = new WebClient();
                    webClient.Proxy = null;
                    webClient.DownloadProgressChanged += downloadFile_DownloadProgressChanged;
                    webClient.DownloadFileCompleted   += downloadFile_DownloadFileCompleted;

                    StopWatch.Start();

                    webClient.DownloadFileAsync(new Uri(Configs.Settings.ServerFolderUrl + file.Name), file.Name);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    throw;
                }
            }
예제 #2
0
            public static List <Configs.File> ProcessPatchList(string[] list)
            {
                List <Configs.File> files = new List <Configs.File>();

                try
                {
                    for (int i = 0; i < list.Length; i++)
                    {
                        string   line      = list[i];
                        string[] data      = line.Split(' ');
                        FileInfo localFile = new FileInfo(data[0]);
                        string   fileName  = data[0];
                        long     fileSize  = Convert.ToInt64(data[2]);
                        string   fileHash  = data[1];


                        Configs.File nf = new Configs.File();
                        nf.Name       = fileName;
                        nf.Size       = fileSize;
                        nf.Hash       = fileHash;
                        nf.IsUpToDate = File.Exists(fileName) && localFile.Length == fileSize && (!Configs.Settings.CheckFilesByHash || GetMd5HashFromFile(fileName) == fileHash);
                        files.Add(nf);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(Texts.GetText("PATCHLISTPROCESSORERROR") + "\n" + ex.Message);
                }
                return(files);
            }