Skip to content

Commit 5e83146

Browse files
committed
Fix: Fixed IO Error in RunCompatibilityTroubleshooterAsync (#13920)
1 parent 9e14906 commit 5e83146

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Files.App/Utils/Shell/LaunchHelper.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,20 @@ public static Task<bool> LaunchAppAsync(string application, string arguments, st
3434
public static Task<bool> RunCompatibilityTroubleshooterAsync(string filePath)
3535
{
3636
var compatibilityTroubleshooterAnswerFile = Path.Combine(Path.GetTempPath(), "CompatibilityTroubleshooterAnswerFile.xml");
37-
File.WriteAllText(compatibilityTroubleshooterAnswerFile, string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Answers Version=\"1.0\"><Interaction ID=\"IT_LaunchMethod\"><Value>CompatTab</Value></Interaction><Interaction ID=\"IT_BrowseForFile\"><Value>{0}</Value></Interaction></Answers>", filePath));
37+
38+
try
39+
{
40+
File.WriteAllText(compatibilityTroubleshooterAnswerFile, string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Answers Version=\"1.0\"><Interaction ID=\"IT_LaunchMethod\"><Value>CompatTab</Value></Interaction><Interaction ID=\"IT_BrowseForFile\"><Value>{0}</Value></Interaction></Answers>", filePath));
41+
}
42+
catch (IOException)
43+
{
44+
// Try with a different file name
45+
SafetyExtensions.IgnoreExceptions(() =>
46+
{
47+
compatibilityTroubleshooterAnswerFile = Path.Combine(Path.GetTempPath(), "CompatibilityTroubleshooterAnswerFile1.xml");
48+
File.WriteAllText(compatibilityTroubleshooterAnswerFile, string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Answers Version=\"1.0\"><Interaction ID=\"IT_LaunchMethod\"><Value>CompatTab</Value></Interaction><Interaction ID=\"IT_BrowseForFile\"><Value>{0}</Value></Interaction></Answers>", filePath));
49+
});
50+
}
3851

3952
return HandleApplicationLaunch("MSDT.exe", $"/id PCWDiagnostic /af \"{compatibilityTroubleshooterAnswerFile}\"", "");
4053
}

0 commit comments

Comments
 (0)