コード例 #1
0
        public void WriteToFile(string FileName, bool Overwrite = true)
        {
            IFileSystemImageResult Res = ISO.CreateResultImage();
            IStream ImgStream          = (IStream)Res.ImageStream;

            if (ImgStream != null)
            {
                STATSTG Stat;
                ImgStream.Stat(out Stat, 0x1);

                if (File.Exists(FileName))
                {
                    if (Overwrite)
                    {
                        File.Delete(FileName);
                    }
                    else
                    {
                        throw new Exception("File already exists: " + FileName);
                    }
                }

                IStream OutStream;
                SHCreateStreamOnFile(FileName, 0x1001, out OutStream);

                ImgStream.CopyTo(OutStream, Stat.cbSize, IntPtr.Zero, IntPtr.Zero);
                OutStream.Commit(0);
            }
        }