private void CreateMaterial(object sender, RoutedEventArgs e) { string materialName = string.Empty; for (int i = 0; ; i++) { string tryName = "NewMaterial"; if (i > 0) { tryName = tryName + "_" + Convert.ToString(i); } if (!File.Exists(currentDirectory + @"\" + tryName + ".gmat")) { materialName = currentDirectory + @"\" + tryName + ".gmat"; break; } } string UniqueName = materialName.Substring(workDirectory.Length); string fileName = System.IO.Path.GetFileName(materialName); IGCore.CreateMaterial(UniqueName); GetFiles(currentDirectory); browserListBox.SelectedItem = GetListBoxItemByName(fileName); mainWindow.GetMaterialPropertiesByUniqueName(UniqueName); }