예제 #1
0
 private void FtpUploader_DoWork(object sender, DoWorkEventArgs e)
 {
     this.ftp = new FTPConnection();
     try
     {
         this.args = (FtpUploaderArgs) e.Argument;
     }
     catch
     {
         this.Errors.Add(new ArgumentNullException("FtpUploader must be passed an instance of FtpUploaderArgs."));
         return;
     }
     string dir = (this.args.Platform == IsoEntryPlatform.Xbox360) ? "00007000" : "00005000";
     string str2 = string.Concat(new object[] { this.args.SourcePath, this.args.TitleID, Path.DirectorySeparatorChar, dir, Path.DirectorySeparatorChar });
     this.ftp.ServerAddress = this.args.Ip;
     this.ftp.UserName = this.args.User;
     this.ftp.Password = this.args.Pass;
     this.ftp.AutoLogin = true;
     try
     {
         this.ftp.Connect();
     }
     catch (Exception exception)
     {
         this.Errors.Add(exception);
         return;
     }
     this.ftp.ChangeWorkingDirectory("Hdd1/Content/0000000000000000");
     if (!this.dirExists(this.args.TitleID))
     {
         this.ftp.CreateDirectory(this.args.TitleID);
     }
     this.ftp.ChangeWorkingDirectory(this.args.TitleID);
     if (!this.dirExists(dir))
     {
         this.ftp.CreateDirectory(dir);
     }
     this.ftp.ChangeWorkingDirectory(dir);
     if (!this.dirExists(this.args.ContainerID + ".data"))
     {
         this.ftp.CreateDirectory(this.args.ContainerID + ".data");
     }
     else
     {
         this.clearDir(this.args.ContainerID + ".data");
     }
     if (this.fileExists(this.args.ContainerID))
     {
         this.ftp.DeleteFile(this.args.ContainerID);
     }
     base.ReportProgress(1, "Uploading GOD header...");
     FileStream srcStream = new FileStream(str2 + this.args.ContainerID, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
     this.ftp.UploadStream(srcStream, this.args.ContainerID);
     this.ftp.ChangeWorkingDirectory(this.args.ContainerID + ".data");
     int percentProgress = 0;
     string[] files = Directory.GetFiles(str2 + this.args.ContainerID + ".data");
     foreach (string str3 in files)
     {
         string remoteFile = str3.Substring(str3.LastIndexOf('\\') + 1);
         base.ReportProgress(percentProgress, "Uploading '" + remoteFile + "'...");
         FileStream stream2 = new FileStream(str3, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
         this.ftp.UploadStream(stream2, remoteFile);
         percentProgress += (int) Math.Floor((double) ((1f / ((float) files.Length)) * 100f));
     }
     this.ftp.Close();
     this.Errors.Clear();
     base.ReportProgress(100, "Uploaded");
 }
예제 #2
0
        private void FtpUploader_DoWork(object sender, DoWorkEventArgs e)
        {
            this.ftp = new FTPConnection();
            try
            {
                this.args = (FtpUploaderArgs)e.Argument;
            }
            catch
            {
                this.Errors.Add(new ArgumentNullException("FtpUploader must be passed an instance of FtpUploaderArgs."));
                return;
            }
            string dir  = (this.args.Platform == IsoEntryPlatform.Xbox360) ? "00007000" : "00005000";
            string str2 = string.Concat(new object[] { this.args.SourcePath, this.args.TitleID, Path.DirectorySeparatorChar, dir, Path.DirectorySeparatorChar });

            this.ftp.ServerAddress = this.args.Ip;
            this.ftp.UserName      = this.args.User;
            this.ftp.Password      = this.args.Pass;
            this.ftp.AutoLogin     = true;
            try
            {
                this.ftp.Connect();
            }
            catch (Exception exception)
            {
                this.Errors.Add(exception);
                return;
            }
            this.ftp.ChangeWorkingDirectory("Hdd1/Content/0000000000000000");
            if (!this.dirExists(this.args.TitleID))
            {
                this.ftp.CreateDirectory(this.args.TitleID);
            }
            this.ftp.ChangeWorkingDirectory(this.args.TitleID);
            if (!this.dirExists(dir))
            {
                this.ftp.CreateDirectory(dir);
            }
            this.ftp.ChangeWorkingDirectory(dir);
            if (!this.dirExists(this.args.ContainerID + ".data"))
            {
                this.ftp.CreateDirectory(this.args.ContainerID + ".data");
            }
            else
            {
                this.clearDir(this.args.ContainerID + ".data");
            }
            if (this.fileExists(this.args.ContainerID))
            {
                this.ftp.DeleteFile(this.args.ContainerID);
            }
            base.ReportProgress(1, "Uploading GOD header...");
            FileStream srcStream = new FileStream(str2 + this.args.ContainerID, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            this.ftp.UploadStream(srcStream, this.args.ContainerID);
            this.ftp.ChangeWorkingDirectory(this.args.ContainerID + ".data");
            int percentProgress = 0;

            string[] files = Directory.GetFiles(str2 + this.args.ContainerID + ".data");
            foreach (string str3 in files)
            {
                string remoteFile = str3.Substring(str3.LastIndexOf('\\') + 1);
                base.ReportProgress(percentProgress, "Uploading '" + remoteFile + "'...");
                FileStream stream2 = new FileStream(str3, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                this.ftp.UploadStream(stream2, remoteFile);
                percentProgress += (int)Math.Floor((double)((1f / ((float)files.Length)) * 100f));
            }
            this.ftp.Close();
            this.Errors.Clear();
            base.ReportProgress(100, "Uploaded");
        }