为了方便和朋友一起玩Minecraft而随便制作的统一更新工具。
工具介绍
技术简述
文件选择窗口
FileSelectButton1 2 3 4 5 6 7 8 9 10
| private void button1_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false; dialog.Title = "请选“HMCL.exe”"; dialog.Filter = "HMCL Launcher(*.exe)|*.exe"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.file = dialog.FileName; textBox1.Text = this.file; } }
|
路径获取
FilePath1 2 3 4 5 6
| var strArray = this.file.Split('\\'); for(int i = 0; i < strArray.Length - 1; i++) { path = path + strArray[i] + '\\'; } string cfgPath = path + ".minecraft\\versions\\1.16.5\\CustomSkinLoader"; string modPath = path + ".minecraft\\versions\\1.16.5\\mods";
|
写出Resources中的资源
WriteResources1 2
| byte[] buff = Properties.Resources.CustomSkinLoader; File.WriteAllBytes(cfgPath + "\\CustomSkinLoader.json", buff);
|
笔记
- 主要问题出现在写出Resources中的资源上,以此文章记录以保留。
开发环境
VS2017