private void createDirs(string str) { string[] dirs = str.Split('\\'); string new_str = String.Empty; foreach (string dir in dirs) { new_str += dir + "\\"; if (Directory.Exists(new_str) == false) { try { Directory.CreateDirectory(new_str); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error creating directories"); } } } }