コード例 #1
0
        /// <summary>
        /// Starts the thread creating the ISO file
        /// </summary>
        public void bgCreator_DoWork(object sender, DoWorkEventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            try
            {
                streamReader = new FileStream(Handle, FileAccess.Read, BUFFER);
                streamWriter = createFileStream(PathToIso, BUFFER);
                PathToIso    = streamWriter.Name;
                //streamWriter = new FileStream(PathToIso, FileMode.Create, FileAccess.Write, FileShare.Read, BUFFER);

                byte[] buffer = new byte[BUFFER];

                //Read buffer blocks from source and write them to the ISO file
                do
                {
                    /*if (bgCreator.CancellationPending)
                     * {
                     *  e.Cancel = true;
                     *  Stop();
                     *  break;
                     * }*/

                    streamReader.Read(buffer, 0, BUFFER);
                    streamWriter.Write(buffer, 0, BUFFER);
                    byte[] bufferClone = buffer.ToArray();

                    if (OnProgress != null)
                    {
                        //Progress in percent
                        int          percent = Convert.ToInt32((streamWriter.Length * 100) / MediumSize);
                        EventIsoArgs eArgs   = new EventIsoArgs(streamWriter.Position, percent);
                        OnProgress(eArgs);
                    }
                } while (streamReader.Position == streamWriter.Position);
            }
            catch (Exception ex)
            {
                if (OnMessage != null)
                {
                    EventIsoArgs eArgs = new EventIsoArgs("Error while creating the image: " + ex.Message);
                    OnMessage(eArgs);
                }
            }
            finally
            {
                CloseAll();

                if (OnFinish != null)
                {
                    EventIsoArgs eArgs = new EventIsoArgs(stopWatch.Elapsed);
                    OnFinish(eArgs);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Aborts the creation of the image and deletes it
        /// </summary>
        public void Stop()
        {
            CloseAll();

            if (File.Exists(PathToIso))
            {
                File.Delete(PathToIso);
            }

            if (OnMessage != null)
            {
                EventIsoArgs e = new EventIsoArgs(@"Creation of the images was canceled");
                OnMessage(e);
            }
        }
コード例 #3
0
        /// <summary>
        /// Starts the thread creating the ISO file
        /// </summary>
        public void bgCreator_DoWork(object sender, DoWorkEventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            try
            {
                DriveInfo driveInfo = new DriveInfo(System.IO.Path.GetPathRoot(SourceDriveName));
                if (driveInfo.IsReady)
                {
                    DiscUtils.Iso9660.CDBuilder builder = new DiscUtils.Iso9660.CDBuilder();
                    builder.UseJoliet        = true;
                    builder.VolumeIdentifier = driveInfo.VolumeLabel;
                    DirectoryInfo di = new DirectoryInfo(SourceDriveName);
                    PopulateFromFolder(builder, di, di.FullName);
                    builder.Build(PathToIso);
                }
            }
            catch (Exception ex)
            {
                if (OnMessage != null)
                {
                    EventIsoArgs eArgs = new EventIsoArgs("Error while creating the image: " + ex.Message);
                    OnMessage(eArgs);
                }
            }
            finally
            {
                CloseAll();

                if (OnFinish != null)
                {
                    EventIsoArgs eArgs = new EventIsoArgs(stopWatch.Elapsed);
                    OnFinish(eArgs);
                }
            }
        }