Vikot106's Blog.

程序:补丁更新工具

字数统计: 215阅读时长: 1 min
2020/01/07 Share

为了方便和朋友一起玩Minecraft而随便制作的统一更新工具。

工具介绍

  • 截图

snap

  • 单文件工具,打开即可使用。

技术简述

文件选择窗口

FileSelectButton
1
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;
}
}

路径获取

FilePath
1
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中的资源

WriteResources
1
2
byte[] buff = Properties.Resources.CustomSkinLoader;
File.WriteAllBytes(cfgPath + "\\CustomSkinLoader.json", buff);

笔记

  • 主要问题出现在写出Resources中的资源上,以此文章记录以保留。

开发环境

VS2017

CATALOG
  1. 1. 工具介绍
    1. 1.1. 技术简述
      1. 1.1.1. 文件选择窗口
      2. 1.1.2. 路径获取
      3. 1.1.3. 写出Resources中的资源
    2. 1.2. 笔记
  2. 2. 开发环境