defaultValues, Dispose fix

master
Harald Wolff 2017-12-07 20:17:29 +01:00
parent 580cf6a1d8
commit 197884e101
1 changed files with 9 additions and 3 deletions

12
JSON.cs
View File

@ -127,9 +127,11 @@ namespace sharp.json
}
public void WriteTo(String filename,bool pretty)
{
FileStream fs = new FileStream(filename, FileMode.Create);
WriteTo(fs,pretty);
fs.Close();
using (FileStream fs = new FileStream(filename, FileMode.Create))
{
WriteTo(fs, pretty);
fs.Close();
}
}
public static JSON ReadFrom(string filename)
@ -161,6 +163,10 @@ namespace sharp.json
} catch (FileNotFoundException e){
return defaultValue;
}
if (source.Equals(""))
{
return defaultValue;
}
return parser.Parse(source);
}