Skip to content

Commit ce3ef4a

Browse files
fix: Improve path handling in settings to support both single and double backslashes
- Normalize path handling in LoadSettings method - Handle both single and double backslash formats - Combine paths relative to application directory - Remove leading backslashes for proper path resolution Fixes #2
1 parent bbb3d0c commit ce3ef4a

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

MainWindow.xaml.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ private void LoadSettings()
3636
{
3737
string jsonContent = File.ReadAllText(appSettingsPath);
3838
JObject settings = JObject.Parse(jsonContent);
39-
40-
// Try to get the modelPath property
41-
JToken? modelPathToken = settings["modelPath"];
42-
if (modelPathToken != null && modelPathToken.Type == JTokenType.String)
43-
{
44-
modelPath = modelPathToken.ToString();
45-
}
39+
// Try to get the modelPath property
40+
JToken? modelPathToken = settings["modelPath"];
41+
if (modelPathToken != null && modelPathToken.Type == JTokenType.String)
42+
{
43+
// Get the path and normalize it
44+
modelPath = Path.GetFullPath(Path.Combine(
45+
AppDomain.CurrentDomain.BaseDirectory,
46+
modelPathToken.ToString().TrimStart('\\')
47+
));
48+
}
4649
}
4750

4851
if (string.IsNullOrEmpty(modelPath))

0 commit comments

Comments
 (0)