public void ToFile(string filename, bool overwrite = false, bool arrange = true)
{
if (string.IsNullOrWhiteSpace(filename))
throw new ArgumentNullException("filename");
if (!overwrite && File.Exists(filename))
throw new ArgumentException("File already exists", "filename");
var icoBytes = ToBytes(arrange);
try
{
File.WriteAllBytes(filename, icoBytes);
}
catch (Exception ex)
{
throw new ArgumentException("Unable to write file", "filename", ex);
}
}