public void AdhocMgrTest() { IDot11AdHocManager AdHocManager = new(); cManagerSink mSink = new(); using var pConnectionPointContainer = new ComConnectionPoint(AdHocManager, mSink); var networks = AdHocManager.GetIEnumDot11AdHocNetworks(); IDot11AdHocNetwork myNet = null; foreach (var network in new Vanara.Collections.IEnumFromCom <IDot11AdHocNetwork>(networks.Next, networks.Reset)) { var ssid = network.GetSSID(); TestContext.WriteLine("\tssid = {0}", ssid); if (ssid == ADHOC_SSID) { myNet = network; } } var sink = new cSink(); if (myNet is not null) { using var netcp = new ComConnectionPoint(myNet, sink); myNet.Connect(ADHOC_PWD, geoId, false, false); } else { var securitySettings = new cSecuritySettings(); myNet = AdHocManager.CreateNetwork(ADHOC_SSID, ADHOC_PWD, geoId, default, securitySettings);
/// <summary>Burns data files to disc in a single session using files from a single directory tree.</summary> /// <param name="recorder">Burning Device. Must be initialized.</param> /// <param name="path">Directory of files to burn.</param> public static void BurnDirectory(this IDiscRecorder2 recorder, string path, string imageName = "IMAPI Sample") { // Define the new disc format and set the recorder var dataWriterImage = new IDiscFormat2Data { Recorder = recorder }; if (!dataWriterImage.IsRecorderSupported(recorder)) { Console.WriteLine("The recorder is not supported"); return; } if (!dataWriterImage.IsCurrentMediaSupported(recorder)) { Console.WriteLine("The current media is not supported"); return; } dataWriterImage.ClientName = imageName; // Create an image stream for a specified directory. // Create a new file system image and retrieve the root directory var fsi = new IFileSystemImage { // Set the media size FreeMediaBlocks = dataWriterImage.FreeSectorsOnMedia, // Use legacy ISO 9660 Format FileSystemsToCreate = FsiFileSystems.FsiFileSystemUDF }; // Add the directory to the disc file system IFsiDirectoryItem dir = fsi.Root; Console.WriteLine(); Console.Write("Adding files to image:".PadRight(80)); using (var eventDisp = new ComConnectionPoint(fsi, new DFileSystemImageEventsSink(AddTreeUpdate))) dir.AddTree(path, false); Console.WriteLine(); // Create an image from the file system Console.WriteLine("\nWriting content to disc..."); IFileSystemImageResult result = fsi.CreateResultImage(); // Data stream sent to the burning device IStream stream = result.ImageStream; // Write the image stream to disc using the specified recorder. using (var eventDisp = new ComConnectionPoint(dataWriterImage, new DDiscFormat2DataEventsSink(WriteUpdate))) dataWriterImage.Write(stream); // Burn the stream to disc Console.WriteLine("----- Finished writing content -----");