Beispiel #1
0
        public string Download(string host, string fileName, string userName, string password, MessageQueue message, string playerName)
        {
            try
            {
                FileInfo  fi      = new FileInfo(fileName);
                WebClient request = new WebClient();

                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
                {
                    request.Credentials = new NetworkCredential(userName, password);
                }

                byte[] fileData = request.DownloadData(@"ftp://" + host + "/" + fi.Name);

                string dropFileName = WOTHelper.GetTempFolder() + @"\" + fi.Name;
                //will dot this at a later stage
                //File.WriteAllBytes(dropFileName, WOTStatistics.Core.GZIP.Decompress(fileData));
                File.WriteAllBytes(dropFileName, fileData);

                message.Add("Info : Retrieved file from FTP. [" + playerName + "]");
                return(dropFileName);
            }
            catch (Exception ex)
            {
                message.Add("Error : " + ex.Message);
                return(fileName);
            }
        }