public void Save(Stream stream, MultiIconFormat format) { switch (format) { case MultiIconFormat.ICO: if (mSelectedIndex == -1) { throw new InvalidIconSelectionException(); } new IconFormat().Save(this, stream); break; case MultiIconFormat.ICL: new NEFormat().Save(this, stream); break; case MultiIconFormat.DLL: new PEFormat().Save(this, stream); break; case MultiIconFormat.EXE: case MultiIconFormat.OCX: case MultiIconFormat.CPL: case MultiIconFormat.SRC: throw new NotSupportedException("File format not supported"); default: throw new NotSupportedException("Unknow file type destination, Icons can't be saved"); } }
public void Save(string fileName, MultiIconFormat format) { FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite); try { Save(fs, format); } finally { if (fs != null) { fs.Close(); } } }