Exemple #1
0
        /// <summary>
        /// Burns a boot image and data files to disc in a single session
        /// using files from a single directory tree.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        /// <param name="path">Directory of files to burn.
        /// \\winbuilds\release\winmain\latest.tst\amd64fre\en-us\skus.cmi\staged\windows
        /// </param>
        /// <param name="bootFile">Path and filename of boot image.
        /// \\winbuilds\release\winmain\latest.tst\x86fre\bin\etfsboot.com
        /// </param>
        public void CreateBootDisc(IDiscRecorder2 recorder, String path, String bootFile)
        {
            // -------- Adding Boot Image Code -----
            Console.WriteLine("Creating BootOptions");
            IBootOptions bootOptions = new MsftBootOptions();

            bootOptions.Manufacturer = "Microsoft";
            bootOptions.PlatformId   = PlatformId.PlatformX86;
            bootOptions.Emulation    = EmulationType.EmulationNone;

            // Need stream for boot image file
            Console.WriteLine("Creating IStream for file {0}", bootFile);
            IStream iStream = new AStream(
                new FileStream(bootFile, FileMode.Open,
                               FileAccess.Read,
                               FileShare.Read));

            bootOptions.AssignBootImage(iStream);

            // Create disc file system image (ISO9660 in this example)
            IFileSystemImage fsi = new MsftFileSystemImage();

            fsi.FreeMediaBlocks     = -1; // Enables larger-than-CD image
            fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660 |
                                      FsiFileSystems.FsiFileSystemJoliet |
                                      FsiFileSystems.FsiFileSystemUDF;

            // Hooking bootStream to FileSystemObject
            fsi.BootImageOptions = bootOptions;

            // Hooking content files FileSystemObject
            fsi.Root.AddTree(path, false);

            IFileSystemImageResult result = fsi.CreateResultImage();
            IStream stream = result.ImageStream;

            // Create and write stream to disc using the specified recorder.
            IDiscFormat2Data dataWriterBurn = new MsftDiscFormat2Data();

            dataWriterBurn.Recorder   = recorder;
            dataWriterBurn.ClientName = "IMAPI Sample";
            dataWriterBurn.Write(stream);

            Console.WriteLine("----- Finished writing content -----");
        }
        /// <summary>
        /// Burns a boot image and data files to disc in a single session 
        /// using files from a single directory tree.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        /// <param name="path">Directory of files to burn.
        /// \\winbuilds\release\winmain\latest.tst\amd64fre\en-us\skus.cmi\staged\windows
        /// </param>
        /// <param name="bootFile">Path and filename of boot image.
        /// \\winbuilds\release\winmain\latest.tst\x86fre\bin\etfsboot.com
        /// </param>
        public void CreateBootDisc(IDiscRecorder2 recorder, String path, String bootFile)
        {
            // -------- Adding Boot Image Code -----
            Console.WriteLine("Creating BootOptions");
            IBootOptions bootOptions = new MsftBootOptions();
            bootOptions.Manufacturer = "Microsoft";
            bootOptions.PlatformId = PlatformId.PlatformX86;
            bootOptions.Emulation = EmulationType.EmulationNone;

            // Need stream for boot image file
            Console.WriteLine("Creating IStream for file {0}", bootFile);
            IStream iStream = new AStream(
                              new FileStream(bootFile, FileMode.Open,
                                                       FileAccess.Read,
                                                       FileShare.Read));
            bootOptions.AssignBootImage(iStream);

            // Create disc file system image (ISO9660 in this example)
            IFileSystemImage fsi = new MsftFileSystemImage();
            fsi.FreeMediaBlocks = -1; // Enables larger-than-CD image
            fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660 |
                                      FsiFileSystems.FsiFileSystemJoliet  |
                                      FsiFileSystems.FsiFileSystemUDF;

            // Hooking bootStream to FileSystemObject
            fsi.BootImageOptions = bootOptions;

            // Hooking content files FileSystemObject
            fsi.Root.AddTree(path, false);

            IFileSystemImageResult result = fsi.CreateResultImage();
            IStream stream= result.ImageStream;

            // Create and write stream to disc using the specified recorder.
            IDiscFormat2Data dataWriterBurn = new MsftDiscFormat2Data();
            dataWriterBurn.Recorder = recorder;
            dataWriterBurn.ClientName = "IMAPI Sample";
            dataWriterBurn.Write(stream);

            Console.WriteLine("----- Finished writing content -----");
        }