Wrap file system export write in try/catch.
This commit is contained in:
parent
bb5088ae6c
commit
e25ca32022
|
@ -297,9 +297,9 @@ namespace ColorTool
|
|||
Console.Write("\x1b[m");
|
||||
}
|
||||
|
||||
private static IntPtr GetStdOutputHandle()
|
||||
{
|
||||
return GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
private static IntPtr GetStdOutputHandle()
|
||||
{
|
||||
return GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
}
|
||||
|
||||
static void PrintSchemes()
|
||||
|
@ -433,21 +433,29 @@ namespace ColorTool
|
|||
bool success = GetConsoleScreenBufferInfoEx(hOut, ref csbiex);
|
||||
if (success)
|
||||
{
|
||||
using (System.IO.StreamWriter file = new System.IO.StreamWriter(outputPath))
|
||||
try
|
||||
{
|
||||
file.WriteLine("[table]");
|
||||
for (int i = 0; i < 16; i++)
|
||||
// StreamWriter can fail for a variety of file system reasons so catch exceptions and print message.
|
||||
using (System.IO.StreamWriter file = new System.IO.StreamWriter(outputPath))
|
||||
{
|
||||
string line = IniSchemeParser.COLOR_NAMES[i];
|
||||
line += " = ";
|
||||
uint color = csbiex.ColorTable[i];
|
||||
uint r = color & (0x000000ff);
|
||||
uint g = (color & (0x0000ff00)) >> 8;
|
||||
uint b = (color & (0x00ff0000)) >> 16;
|
||||
line += r + "," + g + "," + b;
|
||||
file.WriteLine(line);
|
||||
file.WriteLine("[table]");
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
string line = IniSchemeParser.COLOR_NAMES[i];
|
||||
line += " = ";
|
||||
uint color = csbiex.ColorTable[i];
|
||||
uint r = color & (0x000000ff);
|
||||
uint g = (color & (0x0000ff00)) >> 8;
|
||||
uint b = (color & (0x00ff0000)) >> 16;
|
||||
line += r + "," + g + "," + b;
|
||||
file.WriteLine(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue