You can use the String.Trim method, for example:
foreach (string s in paths) { MessageBox.Show(s.Trim()); }
Alternatively, you can exclude spaces before they enter paths , for example:
files.Split(new[]{';', ' '}, StringSplitOptions.RemoveEmptyEntries);
source share