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 ...

screenshot

  • And how does creating an ISO in C # differ from any other language? “You take an image, you make an image!” (C) Either you need a third-party library that knows how, or you need to know the ISO format and create the file manually. There are no tools in C # (as well as in any other language). - VladD
  • It is required to implement the functionality of creating an ISO image of a flash drive using C # and, because I have not previously encountered a similar question, I ask the community for advice - LivAlex
  • Well, in fact, VladD has already given you the answer, look for a library that has a binding to C # and which can do it or write the code yourself. What is the problem? You do not know what to choose, or can not ISO specification google? - PaulD
  • There are several problems: 1. I found the .Net DiscUtils library, but I cannot create the file correctly 2. Obviously, in my previous comment, I noticed that I encountered this problem for the first time, so the problem is not to google, but what exactly is google, because . those problems that I encountered while using the above library are not described (at least I did not find a description) 3. and yes, if someone has already encountered a similar issue, I would like to know what was used to solve the problem - LivAlex
  • one
    The @Helisia iso image is a sector-specific copy of the disk. It can not be a zip-archive! - Pavel Mayorov

2 answers 2

  1. Try to use instead of a flash drive with data any folder on your hard disk.
  2. I don’t shave in C # much, but I think you should try a way with a zip archive. Read more here.
  • I tend to this idea, because with iso-files there is not much work :) - LivAlex

Not looking at the fact that ISO is opened by archivers, it is not a zip archive. First, Ioshosh is a sector-by-sector copy of a disk. Secondly, there may be boot sector data (that is, Partition created as Active). In zip, there is no such information at all and cannot be in principle.

I do not know the given situation of the author of the question ... It is quite possible that a crutch with a zip archive in his case will be rolled. But in general this is the wrong way.

And there are only 2 industrial paths:

  1. Search for a library with implemented creation of virtual images of logical disks
  2. write your own (stupid way, if you honestly.)

"not enough disk space" (although there is plenty of disk space)

^ This may apply to:

  • the hard drive of the winchester where you place isoshka
  • the hard disk drive where you place temporary files (for example drive C)
  • Isochka itself (for example, some limits on the creation of an iso-file. That is, try to stick 701 megabytes when a certain limit says there should be 700) (just a guess, I don’t know what kind of limit there may be)

And damn, he knows what options. In this case, this is too general a mistake that does not tell me anything. And with such an abundance of options, it is difficult to believe you that there really is space on the disk.

It is necessary to look at exactly what step it pops up and on all the data that you post. And on the setting up creating ISOs ....

In general ... if it is NOT important to you to follow the full ISO specification, create a zip and don’t suffer. In theory, this can be a ride for your needs.

If it is important for you to get a real ISO that meets all the specifications - or understand in more detail by asking on the forum dedicated to this library (or on the github branch of problems, if there is one) or look for another library.

I do not advise you to reinvent your bike.