Skip to content

Commit 727c47b

Browse files
committed
Update PacketViewModel.cs
1 parent e64fa1f commit 727c47b

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/ViewModels/PacketViewModel.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ await DifferentialCore.Instance.Clean(ConfigModel.AppDirectory,
181181
}
182182

183183
// Create and save ConfigInfo JSON file
184-
await CreateConfigInfoFile();
184+
var configFile = await CreateConfigInfoFile();
185185

186186
var directoryInfo = new DirectoryInfo(ConfigModel.PatchDirectory);
187187
var parentDirectory = directoryInfo.Parent!.FullName;
@@ -201,6 +201,7 @@ await DifferentialCore.Instance.Clean(ConfigModel.AppDirectory,
201201
{
202202
ConfigModel.Path = packetInfo.FullName;
203203
await MessageBox.ShowAsync("Build success", "Success", Buttons.OK);
204+
OpenFileDirectoryAndSelectFile(configFile);
204205
}
205206
else
206207
{
@@ -354,7 +355,7 @@ private async Task<string> CreateConfigInfoFile()
354355
};
355356

356357
var json = JsonConvert.SerializeObject(configInfo, Formatting.Indented);
357-
var configFilePath = Path.Combine(ConfigModel.PatchDirectory, "update_config.json");
358+
var configFilePath = Path.Combine(AppContext.BaseDirectory, "update_config.json");
358359

359360
await File.WriteAllTextAsync(configFilePath, json, Encoding.UTF8);
360361

@@ -497,4 +498,19 @@ private void CreateDirectory()
497498

498499
ConfigModel.PatchDirectory = patchDir;
499500
}
501+
502+
static void OpenFileDirectoryAndSelectFile(string filePath)
503+
{
504+
if (!File.Exists(filePath))
505+
{
506+
throw new FileNotFoundException("The file is not exists!", filePath);
507+
}
508+
509+
Process.Start(new ProcessStartInfo
510+
{
511+
FileName = "explorer.exe",
512+
Arguments = $"/select, \"{filePath}\"", // /select 参数用于选中文件
513+
UseShellExecute = true
514+
});
515+
}
500516
}

0 commit comments

Comments
 (0)