I was concerned with the question of a software method of creating ISO images from a C # project. How best to implement a similar trick? Is there a DiskUtils library, but is it third-party, did someone use it once, or are there any other ways?
UPD. I tried to use the .NET DiscUtils library ( http://discutils.codeplex.com/ ) and ran into the problem of building the actual iso image. According to the library documentation, the image file is built as follows:
How to create a new ISO:
CDBuilder builder = new CDBuilder ();
builder.UseJoliet = true;
builder.VolumeIdentifier = "A_SAMPLE_DISK";
builder.AddFile (@ "Folder \ Hello.txt", Encoding.ASCII.GetBytes ("Hello World!")); builder.Build (@ "C: \ temp \ sample.iso");You can add files as byte arrays (shown above), as files from the windows filesystem, or as a stream. By using a different file format, you can get a stream to the ISO file, rather than writing it to the Windows filesystem.
My code is:
//обработка сообщения о подключении флешки private void onDriveArrived(object sender, DriveDetectorEventArgs e) { DriveInfo dri = new DriveInfo(e.Drive); if ((dri.DriveType & DriveType.Removable) != DriveType.Removable) return; try { //создаю объект под будущий iso CDBuilder builder = new CDBuilder(); //определяю рут-директорию флешки DirectoryInfo dir = new DirectoryInfo(e.Drive); //подключаю флаг Joliet-он в стандарте ISO9660 позволяет поддерживать //имена файлов более 8 символов builder.UseJoliet = true; //прописываю метку диска - смонтированного в виртуальное устройство iso-образа builder.VolumeIdentifier = "TEST"; //получаю имена с путями всех файлов на флешке List<string> names = GetFilesPathToISO(e.Drive); foreach (string name in names) //каждый файл из списка добавляю в будущий iso builder.AddFile(name, name); //создается iso-файл builder.Build(@"d:\test.iso"); } catch (Exception err) {MessageBox.Show(err.Message + "\n" + err.StackTrace);} } } I launch, insert a flash drive with data, an image begins to be created, reaches a certain point, throws out an exception like "not enough disk space" (although there is plenty of disk space) and interrupts the work. In the created image file when opening it by the archiver there are some empty files. And I don’t know what to do, and there’s really nobody to ask ...
