private void ButtonGen_Click(object sender, EventArgs e)
        {
            string PendingExportStr = "";

            PendingExportStr  = "\"AppState\"\n{\n";
            PendingExportStr += "\t\"appid\"\t\t\"" + this.mAppID.ToString() + "\"\n";
            PendingExportStr += "\t\"Universe\"\t\t\"1\"\n";
            PendingExportStr += "\t\"StateFlags\"\t\t\"4\"\n";
            PendingExportStr += "\t\"installdir\"\t\t\"" + this.textBoxInstallDir.Text + "\"\n";
            PendingExportStr += "\t\"LastUpdated\"\t\t\"" + ConvertDateTimeInt(DateTime.Now).ToString() + "\"\n";
            PendingExportStr += "\t\"UpdateResult\"\t\t\"0\"\n";
            PendingExportStr += "\t\"SizeOnDisk\"\t\t\"1\"\n";
            PendingExportStr += "\t\"buildid\"\t\t\"1\"\n";
            PendingExportStr += "\t\"BytesToDownload\"\t\t\"1\"\n";
            PendingExportStr += "\t\"BytesDownloaded\"\t\t\"1\"\n";
            PendingExportStr += "\t\"AutoUpdateBehavior\"\t\t\"1\"\n";
            PendingExportStr += "\t\"AllowOtherDownloadsWhileRunning\"\t\t\"0\"\n";
            PendingExportStr += "\t\"ScheduledAutoUpdate\"\t\t\"0\"\n";
            PendingExportStr += "\t\"InstalledDepots\"\n\t{\n";
            for (int i = 0; i < this.checkedListBoxDepots.Items.Count; i++)
            {
                if (this.checkedListBoxDepots.GetItemChecked(i))
                {
                    string Password = "";
                    PendingExportStr += "\t\t\"" + DepotList[i].ToString() + "\"\n\t\t{\n";
                    PendingExportStr += "\t\t\t\"manifest\"\t\t\"" +
                                        ContentDownloader.GetSteam3DepotManifestStatic(DepotList[i], mAppID, "public", ref Password) + "\"\n\t\t}\n";
                }
            }
            PendingExportStr += "\t}\n\t\"MountedDepots\"\n\t{\n";
            for (int i = 0; i < this.checkedListBoxDepots.Items.Count; i++)
            {
                if (this.checkedListBoxDepots.GetItemChecked(i))
                {
                    string Password = "";
                    PendingExportStr += "\t\t\"" + DepotList[i].ToString() + "\"";
                    PendingExportStr += "\t\t\"" +
                                        ContentDownloader.GetSteam3DepotManifestStatic(DepotList[i], mAppID, "public", ref Password) + "\"\n";
                }
            }

            PendingExportStr += "\t}\n}";
            this.saveFileDialog1.FileName = "appmanifest_" + mAppID.ToString() + ".acf";
            if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.File.WriteAllText(this.saveFileDialog1.FileName, PendingExportStr);
            }
        }
 private async void FileSelector_LoadAsync(object sender, EventArgs e)
 {
     string Title = this.Text;
     string Password = "";
     if(ManifestID==ContentDownloader.INVALID_MANIFEST_ID)
         ManifestID = ContentDownloader.GetSteam3DepotManifestStatic(DepotID, AppID, Branch,ref Password);
     if (ManifestID == ContentDownloader.INVALID_MANIFEST_ID)
     {
         MessageBox.Show(Properties.Resources.NoManifestID, "FileSelector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
     this.labelManifestID.Text = "ManifestID:" + ManifestID.ToString();
     System.IO.Directory.CreateDirectory(Program.CacheDir);
     var localProtoManifest = DepotDownloader.ProtoManifest.LoadFromFile(string.Format("{0}/{1}.bin",Program.CacheDir, ManifestID));
     if (localProtoManifest!=null)
     {
         depotManifest = localProtoManifest;
     }
     else
     {
         this.Text = "Downloading File List...";
         this.Refresh();
         ContentDownloader.Steam3.RequestDepotKey(DepotID,AppID);
         if(!ContentDownloader.Steam3.DepotKeys.ContainsKey(DepotID))
         {
             MessageBox.Show(Properties.Resources.NoDepotKey, "FileSelector",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
             //return;
             //User may still need to use FileRegex
             Close();
             return;
         }
         byte[] depotKey = ContentDownloader.Steam3.DepotKeys[DepotID];
         //ContentDownloader.Steam3.RequestAppTicket(AppID);
         ContentDownloader.Steam3.RequestAppTicket(DepotID);
         var client = await DepotDownloader.ContentDownloader.GlobalCDNPool.GetConnectionForDepotAsync(AppID, DepotID, depotKey, System.Threading.CancellationToken.None).ConfigureAwait(true);
         var SteamKitdepotManifest = await client.DownloadManifestAsync(DepotID, ManifestID).ConfigureAwait(true);
         if (SteamKitdepotManifest != null)
         {
             localProtoManifest = new ProtoManifest(SteamKitdepotManifest, ManifestID);
             localProtoManifest.SaveToFile(string.Format("{0}/{1}.bin", Program.CacheDir, ManifestID));
             depotManifest = localProtoManifest;
         }
     }
     if(depotManifest!=null)
     {
         foreach (var file in localProtoManifest.Files)
         {
             //Process Dir
             var FilePathSplited = file.FileName.Split('\\');
             List<string> FilePathList = new List<string>(FilePathSplited);
             TreeNode LastNode=null;
             TreeNodeCollection FileNodes = this.treeViewFileList.Nodes;
             while (FilePathList.Count != 0)
             {
                 TreeNode TargetNode = null;
                 foreach (TreeNode Tn in FileNodes)
                 {
                     if (Tn.Text == FilePathList[0])
                     {
                         TargetNode = Tn;
                         break;
                     }
                 }
                 if (TargetNode == null)
                 {
                     LastNode = FileNodes.Add(FilePathList[0]);
                     FileNodes = LastNode.Nodes;
                 }
                 else
                 {
                     FileNodes = TargetNode.Nodes;
                 }
                 FilePathList.RemoveAt(0);
             }
             if(file.Flags!=SteamKit2.EDepotFileFlag.Directory)
             {
                 DepotMaxSize += file.TotalSize;
                 //if(LastNode!=null)
                 LastNode.Tag = file.TotalSize;
             }
         }
         float TargetSize = DepotMaxSize / 1024f;
         if(TargetSize<1024)
         {
             SizeDivisor = 1024f;
             UnitStr = "KB";
         }
         else if(TargetSize/1024f<1024)
         {
             SizeDivisor = 1024 * 1024f;
             UnitStr = "MB";
         }
         else
         {
             SizeDivisor = 1024 * 1024 * 1024f;
             UnitStr = "GB";
         }
         this.labelSize.Text = string.Format("{0}{1}/{2}{1}", 0.ToString("#0.00"), UnitStr, (DepotMaxSize / SizeDivisor).ToString("#0.00"));
     }
     this.Text = Title;
 }