Example #1
0
        private void _AddNode(IFsiDirectoryItem root, IMediaNode node)
        {
            IStream stream = null;

            try
            {
                if (node is DirectoryNode)
                {
                    root.AddTree(node.Path, true);
                }
                else
                {
                    Shell.SHCreateStreamOnFile(node.Path, Shell.STGM_READ | Shell.STGM_SHARE_DENY_WRITE, ref stream);
                    if (stream != null)
                    {
                        root.AddFile(node.Name, stream);
                    }
                }
            }
            finally
            {
                if (stream != null)
                {
                    Marshal.FinalReleaseComObject(stream);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Burns data files to disc in a single session using files from a
        /// single directory tree.
        /// </summary>
        /// <param name="recorder">Burning device.</param>
        /// <param name="path">Directory of files to burn.</param>
        /// <param name="clientName">The friendly name of the client (used to determine recorder reservation conflicts).</param>
        public void BurnDirectory(DiscRecorder recorder, string path, string clientName = "IMAPI Client Record Name")
        {
            if (!recorder.MediaImage.IsRecorderSupported(recorder.Recorder))
            {
                throw new Exception("The recorder is not supported");
            }

            if (!recorder.MediaImage.IsCurrentMediaSupported(recorder.Recorder))
            {
                throw new Exception("The current media is not supported");
            }

            // Set the client name.
            recorder.MediaImage.ClientName = clientName;

            // Create an image stream for a specified directory.
            // Create a new file system image and retrieve the root directory
            IFileSystemImage fsi = new MsftFileSystemImage();

            // Set the media size
            fsi.FreeMediaBlocks = recorder.MediaImage.FreeSectorsOnMedia;

            // Use legacy ISO 9660 Format
            fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660;

            // Add the directory to the disc file system
            IFsiDirectoryItem dir = fsi.Root;

            dir.AddTree(path, false);

            // Write the progress.
            if (recorder.ProgressAction != null)
            {
                recorder.ProgressAction("Writing content to disc.");
            }

            // Create an image from the file system.
            // Data stream sent to the burning device
            IFileSystemImageResult result = fsi.CreateResultImage();
            IStream stream = result.ImageStream;

            DiscFormat2Data_Events progress = recorder.MediaImage as DiscFormat2Data_Events;

            progress.Update += new DiscFormat2Data_EventsHandler(recorder.DiscFormat2Data_ProgressUpdate);

            // Write the image stream to disc using the specified recorder.
            recorder.MediaImage.Write(stream);   // Burn the stream to disc
            progress.Update -= new DiscFormat2Data_EventsHandler(recorder.DiscFormat2Data_ProgressUpdate);

            // Write the progress.
            if (recorder.ProgressAction != null)
            {
                recorder.ProgressAction("Finished writing content.");
            }
        }
        /// <summary>Burns 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.</param>
        public static void BurnDirectory(this IDiscRecorder2 recorder, string path, string imageName = "IMAPI Sample")
        {
            // Define the new disc format and set the recorder
            var dataWriterImage = new IDiscFormat2Data
            {
                Recorder = recorder
            };

            if (!dataWriterImage.IsRecorderSupported(recorder))
            {
                Console.WriteLine("The recorder is not supported");
                return;
            }

            if (!dataWriterImage.IsCurrentMediaSupported(recorder))
            {
                Console.WriteLine("The current media is not supported");
                return;
            }

            dataWriterImage.ClientName = imageName;

            // Create an image stream for a specified directory.

            // Create a new file system image and retrieve the root directory
            var fsi = new IFileSystemImage
            {
                // Set the media size
                FreeMediaBlocks = dataWriterImage.FreeSectorsOnMedia,

                // Use legacy ISO 9660 Format
                FileSystemsToCreate = FsiFileSystems.FsiFileSystemUDF
            };

            // Add the directory to the disc file system
            IFsiDirectoryItem dir = fsi.Root;

            Console.WriteLine();
            Console.Write("Adding files to image:".PadRight(80));
            using (var eventDisp = new ComConnectionPoint(fsi, new DFileSystemImageEventsSink(AddTreeUpdate)))
                dir.AddTree(path, false);
            Console.WriteLine();

            // Create an image from the file system
            Console.WriteLine("\nWriting content to disc...");
            IFileSystemImageResult result = fsi.CreateResultImage();

            // Data stream sent to the burning device
            IStream stream = result.ImageStream;

            // Write the image stream to disc using the specified recorder.
            using (var eventDisp = new ComConnectionPoint(dataWriterImage, new DDiscFormat2DataEventsSink(WriteUpdate)))
                dataWriterImage.Write(stream);                   // Burn the stream to disc

            Console.WriteLine("----- Finished writing content -----");
Example #4
0
        /// <summary>
        /// Burns 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.</param>
        public void BurnDirectory(IDiscRecorder2 recorder, String path)
        {
            // Define the new disc format and set the recorder
            IDiscFormat2Data dataWriterImage = new MsftDiscFormat2Data();

            dataWriterImage.Recorder = recorder;

            if (!dataWriterImage.IsRecorderSupported(recorder))
            {
                Console.WriteLine("The recorder is not supported");
                return;
            }

            if (!dataWriterImage.IsCurrentMediaSupported(recorder))
            {
                Console.WriteLine("The current media is not supported");
                return;
            }

            dataWriterImage.ClientName = "IMAPI Sample";

            // Create an image stream for a specified directory.

            // Create a new file system image and retrieve the root directory
            IFileSystemImage fsi = new MsftFileSystemImage();

            // Set the media size
            fsi.FreeMediaBlocks = dataWriterImage.FreeSectorsOnMedia;

            // Use legacy ISO 9660 Format
            fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660;

            // Add the directory to the disc file system
            IFsiDirectoryItem dir = fsi.Root;

            dir.AddTree(path, false);

            // Create an image from the file system
            Console.WriteLine("Writing content to disc...");
            IFileSystemImageResult result = fsi.CreateResultImage();

            // Data stream sent to the burning device
            IStream stream = result.ImageStream;

            DiscFormat2Data_Events progress = dataWriterImage as DiscFormat2Data_Events;

            progress.Update += new DiscFormat2Data_EventsHandler(DiscFormat2Data_ProgressUpdate);

            // Write the image stream to disc using the specified recorder.
            dataWriterImage.Write(stream);   // Burn the stream to disc

            progress.Update -= new DiscFormat2Data_EventsHandler(DiscFormat2Data_ProgressUpdate);

            Console.WriteLine("----- Finished writing content -----");
        }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rootItem"></param>
 /// <returns></returns>
 private bool AddDir(ref IFsiDirectoryItem rootItem)
 {
     try
     {
         rootItem.AddTree(m_strThisPath, true);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rootItem"></param>
 /// <returns></returns>
 public bool AddToFileSystem(IFsiDirectoryItem rootItem)
 {
     try
     {
         rootItem.AddTree(m_directoryPath, true);
         return(true);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message, "Error adding folder");
         return(false);
     }
 }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rootItem"></param>
 /// <returns></returns>
 public bool AddToFileSystem(IFsiDirectoryItem rootItem)
 {
     try
     {
         rootItem.AddTree(m_directoryPath, true);
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error adding folder",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return(false);
     }
 }
Example #8
0
        public bool tambahkanKeFileSystem(IFsiDirectoryItem rootItem)
        {
            try
            {
                rootItem.AddTree(pathDirektori, true);
                return(true);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Kesalahan menambahkan folder...",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return(false);
            }
        }
Example #9
0
        public bool AddToFileSystem(IFsiDirectoryItem rootItem)
        {
            bool flag;

            try
            {
                rootItem.AddTree(this.m_directoryPath, true);
                flag = true;
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                MessageBox.Show(exception.Message, "Error adding folder", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                flag = false;
            }
            return(flag);
        }
Example #10
0
 public bool AddToFileSystem(IFsiDirectoryItem rootItem)
 {
     try
     {
         rootItem.AddTree(m_directoryPath, true);
         return true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error adding folder",
             MessageBoxButtons.OK,
             MessageBoxIcon.Error);
         return false;
     }
 }
Example #11
0
        /// <summary>
        /// add item to burn data tree
        /// </summary>
        /// <param name="rootItem"></param>
        /// <param name="isBurnDirectoryExist"></param>
        /// <returns></returns>
        public bool AddToFileSystem(IFsiDirectoryItem rootItem)
        {
            try
            {
                var filename = System.IO.Path.GetFileName(_mDirectoryPath);

                IFsiItem item;
                try
                {
                    item = (IFsiItem)rootItem["\\" + filename];
                }
                catch (Exception)
                {
                    item = null;
                }

                if (item != null)
                {
                    IFsiDirectoryItem dirItem = item as IFsiDirectoryItem;
                    foreach (var mediaItem in _mediaItems)
                    {
                        mediaItem.AddToFileSystem(dirItem);
                    }
                }
                else
                {
                    rootItem.AddTree(_mDirectoryPath, true);
                }

                return true;
            }
            catch (Exception ex)
            {
                throw new global::System.InvalidOperationException("Error adding to FileSystem" + ex.Message);
            }
        }
Example #12
0
        private void _AddNode(IFsiDirectoryItem root, IMediaNode node)
        {
            IStream stream = null;

            try
            {
                if (node is DirectoryNode)
                {
                    root.AddTree(node.Path, true);
                }
                else
                {
                    Shell.SHCreateStreamOnFile(node.Path, Shell.STGM_READ | Shell.STGM_SHARE_DENY_WRITE, ref stream);
                    if (stream != null)
                        root.AddFile(node.Name, stream);
                }
            }
            finally
            {
                if (stream != null)
                {
                    Marshal.FinalReleaseComObject(stream);
                }
            }
        }