.NET DiscUtils如何将文件写入vhd(virtaul hdd)

时间:2018-01-29 14:19:49

标签: .net

这里是我的代码

  using (VirtualDisk vhdx = DiscUtils.Vhd.Disk.OpenDisk(vhd_filename, FileAccess.Read))
        {
            FatFileSystem vhdbNtfs = new FatFileSystem(vhdx.Partitions(0).Open());
            string filePathOnDisk = "Win.exe";
            using (FileStream fileOnDisk = new FileStream(filePathOnDisk, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                byte[] buffer = new byte[BUFFERLENGTH - 1 + 1];
                using (Stream file_create = vhdbNtfs.OpenFile(vhdbNtfs.Root.FullName, FileMode.Create))
                {
                    int bytesRead = 0;
                    while ((__InlineAssignHelper(bytesRead, fileOnDisk.Read(buffer, 0, BUFFERLENGTH))) != 0)
                    {
                        file_create.Write(buffer, 0, bytesRead);
                    }
                }
            }
        }

在" vhdbNtfs.OpenFile"

上收到错误

System.IO.FileNotFoundException:'找不到文件'

0 个答案:

没有答案