-
Notifications
You must be signed in to change notification settings - Fork 12
Apply an Image
josemesona edited this page Jun 15, 2016
·
1 revision
This is a C# example showing how to apply an image from a WIM similar to the C++ version on MSDN: Apply an Image from a .wim File
// Path to where the image should be applied
//
var targetPath = @"C:\Folder";
// .wim files contain multiple images. You must specify the image index when interacting
// with them. The index is 1-based meaning index range is 1-N.
//
var imageIndex = 1;
// Get a handle to the .wim container
//
using (var wimHandle = WimgApi.CreateFile(
@"D:\Temp\winpe_arm\media\sources\boot.wim",
WimFileAccess.Read,
WimCreationDisposition.OpenExisting,
WimCreateFileOptions.None,
WimCompressionType.None))
{
// Always set a temporary path
//
WimgApi.SetTemporaryPath(wimHandle, Environment.GetEnvironmentVariable("TEMP"));
// Get a handle to a specific image inside of the .wim
//
using (var imageHandle = WimgApi.LoadImage(wimHandle, imageIndex))
{
// Apply the image
//
WimgApi.ApplyImage(imageHandle, targetPath, WimApplyImageOptions.None);
}
}