I get a list of virtuals machines from my hypervisor and get this kind of string :
Vmid Name File Guest OS Version Annotation\n1 Win7-1 [VMs] Win7-1/Win7-1.vmx windows7_64Guest vmx-19 \n2 TestVM [VMs] TestVM/TestVM.vmx windows9_64Guest vmx-19 \n
Now I want to split this string by \n to get a string[] with :
Vmid Name File Guest OS Version Annotation
1 Win7-1 [VMs] Win7-1/Win7-1.vmx windows7_64Guest vmx-19
2 TestVM [VMs] TestVM/TestVM.vmx windows9_64Guest vmx-19
But I can’t…
client.Connect();
var commandList = client.CreateCommand(@"vim-cmd vmsvc/getallvms");
commandList.Execute();
string[] resultatList = commandList.Result.Split(new string[] { @"\n" }, StringSplitOptions.None);
client.Disconnect();
This is the content of commandList.Result :

And the content of resultatList :

resultatList is an array with just 1 entry instead of 3…
What’s wrong ?
>Solution :
You are using @ so the string \n is litteraly a \ and a n.
Your string have new lines not the 2 chars \ and n.
string[] resultatList = commandList.Result.Split(new string[] { "\n" }, StringSplitOptions.None);
Will split your string.