Skip to content

Commit 2fa84bc

Browse files
committed
fix: add file existence check before opening configuration file
1 parent 981642c commit 2fa84bc

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -817,20 +817,23 @@ private void OnCopyPathClicked()
817817
private void OnOpenFileClicked()
818818
{
819819
string path = configPathField.value;
820-
if (!string.IsNullOrEmpty(path))
820+
try
821821
{
822-
try
822+
if (!File.Exists(path))
823823
{
824-
Process.Start(new System.Diagnostics.ProcessStartInfo
825-
{
826-
FileName = path,
827-
UseShellExecute = true
828-
});
824+
EditorUtility.DisplayDialog("Open File", "The configuration file path does not exist.", "OK");
825+
return;
829826
}
830-
catch (Exception ex)
827+
828+
Process.Start(new ProcessStartInfo
831829
{
832-
McpLog.Error($"Failed to open file: {ex.Message}");
833-
}
830+
FileName = path,
831+
UseShellExecute = true
832+
});
833+
}
834+
catch (Exception ex)
835+
{
836+
McpLog.Error($"Failed to open file: {ex.Message}");
834837
}
835838
}
836839

0 commit comments

Comments
 (0)