Skip to content

Commit 0845649

Browse files
authored
Bug Fix
Saving a sequence in a folder without the necessary permissions caused a crash
1 parent f5059e3 commit 0845649

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

MouseDummy/Frm_MouseDummy.cs

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -337,36 +337,42 @@ private void cmbbx_savedSequences_SelectedIndexChanged(object sender, EventArgs
337337
break;
338338
}
339339
}
340+
try
341+
{
342+
// Save in a file
343+
if (!Directory.Exists("SavedSequences"))
344+
Directory.CreateDirectory("SavedSequences");
345+
File.WriteAllText("SavedSequences\\" + sequenceName + ".sqc", currentSequence);
340346

341-
// Save in a file
342-
if (!Directory.Exists("SavedSequences"))
343-
Directory.CreateDirectory("SavedSequences");
344-
File.WriteAllText("SavedSequences\\" + sequenceName + ".sqc", currentSequence);
345-
346-
// Adds the sequence to the ComboBox
347-
cmbbx_savedSequences.Items.Add(sequenceName);
347+
// Adds the sequence to the ComboBox
348+
cmbbx_savedSequences.Items.Add(sequenceName);
349+
}
350+
catch (Exception ex)
351+
{
352+
MessageBox.Show("The sequence couldn't be saved in your drive, make sure the installation path have the necessary permissions or start the program as Administrator.", "Permissions Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
353+
}
348354
}
349-
}
350-
else if (cmbbx_savedSequences.Items[cmbbx_savedSequences.SelectedIndex].ToString().Contains("+ New"))
351-
{
352-
// Clear the current points
353-
lstbx_points.Items.Clear();
354-
}
355-
else if (cmbbx_savedSequences.Items[cmbbx_savedSequences.SelectedIndex].ToString().Contains("------"))
356-
{
357-
// Does nothing as only serves as separator between options and actual saved sequences
358-
}
359-
else
360-
{
361-
// Clear the current points
362-
lstbx_points.Items.Clear();
355+
else if (cmbbx_savedSequences.Items[cmbbx_savedSequences.SelectedIndex].ToString().Contains("+ New"))
356+
{
357+
// Clear the current points
358+
lstbx_points.Items.Clear();
359+
}
360+
else if (cmbbx_savedSequences.Items[cmbbx_savedSequences.SelectedIndex].ToString().Contains("------"))
361+
{
362+
// Does nothing as only serves as separator between options and actual saved sequences
363+
}
364+
else
365+
{
366+
// Clear the current points
367+
lstbx_points.Items.Clear();
363368

364-
// Load from the file
365-
string[] savedSequence = File.ReadAllText("SavedSequences\\" + cmbbx_savedSequences.SelectedItem + ".sqc").Split("\n");
369+
// Load from the file
370+
string[] savedSequence = File.ReadAllText("SavedSequences\\" + cmbbx_savedSequences.SelectedItem + ".sqc").Split("\n");
366371

367-
lstbx_points.Items.AddRange(savedSequence);
372+
lstbx_points.Items.AddRange(savedSequence);
373+
}
374+
cmbbx_savedSequences.SelectedText = "";
368375
}
369-
cmbbx_savedSequences.SelectedText = "";
370376
}
371377

372378
private void nmrupdwn_actionDelay_ValueChanged(object sender, EventArgs e)

MouseDummy/MouseDummy.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.14.36109.1 d17.14
4+
VisualStudioVersion = 17.14.36109.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MouseDummy", "MouseDummy.csproj", "{3C2FAB0B-4DAE-45E5-94BE-5D69ADBF7462}"
77
EndProject

0 commit comments

Comments
 (0)