public static void SearchVM(ref List <VirtualMachine> VMList) { string ConfigFile; VBoxXML XML; ConfigFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @".VirtualBox\VirtualBox.xml"); if (!File.Exists(ConfigFile)) { return; } XML = new VBoxXML(ConfigFile); var list = XML.ReadAttributes("VirtualBox/Global/MachineRegistry/MachineEntry", "src"); foreach (string path in list) { if (File.Exists(path)) { var VBOX = new VBoxVM(path); VMList.Add(VBOX); } } }
//按照文件后缀判断格式并打开 private void DetectAndOpen(string file) { VirtualMachine VM = null; switch (Path.GetExtension(file)) { case ".vmx": VM = new VMwareVM(file); break; case ".vbox": VM = new VBoxVM(file); break; case ".vmc": VM = new VirtualPC_VM(file); break; } if (VM != null) { OpenVM(VM); } }