Skip to content

Commit 8374f03

Browse files
committed
remove launcherarguments.txt if arguments value is empty
1 parent be6156c commit 8374f03

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public partial class MainWindow : Window
5050
internal static int webglPort = 50000;
5151
internal static int maxProjectCount = 40;
5252

53-
5453
string defaultDateFormat = "dd/MM/yyyy HH:mm:ss";
5554
string adbLogCatArgs = defaultAdbLogCatArgs;
5655

@@ -1496,16 +1495,27 @@ private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEven
14961495
// save arguments to projectsettings folder
14971496
string outputFile = Path.Combine(projectPath, projSettingsFolder, launcherArgumentsFile);
14981497

1499-
try
1498+
if (string.IsNullOrEmpty(newcellValue.Trim()) == true)
15001499
{
1501-
StreamWriter sw = new StreamWriter(outputFile);
1502-
sw.WriteLine(newcellValue);
1503-
sw.Close();
1500+
// its empty value, so we remove the file (to avoid wasting time reading empty file)
1501+
if (File.Exists(outputFile))
1502+
{
1503+
File.Delete(outputFile);
1504+
}
15041505
}
1505-
catch (Exception ex)
1506+
else
15061507
{
1507-
Console.WriteLine("Error saving launcher arguments: " + ex);
1508-
SetStatus("Error saving launcher arguments: " + ex.Message);
1508+
try
1509+
{
1510+
StreamWriter sw = new StreamWriter(outputFile);
1511+
sw.WriteLine(newcellValue);
1512+
sw.Close();
1513+
}
1514+
catch (Exception ex)
1515+
{
1516+
Console.WriteLine("Error saving launcher arguments: " + ex);
1517+
SetStatus("Error saving launcher arguments: " + ex.Message);
1518+
}
15091519
}
15101520
}
15111521
else if (e.Column.DisplayIndex == 6) // platform dropdown

0 commit comments

Comments
 (0)