private void OK_Click(object sender, RoutedEventArgs e) { fileName = this.TextBoxFileName.Text; if (this.type == ICCAssociationType.OutlookEmailMessage) { DialogResult = true; } else if (isFolder) { string folderPath = filePath + fileName; if (System.IO.Directory.Exists(folderPath)) { System.Windows.MessageBox.Show("There is already a folder with the same name in this location.", "Invalid Folder Name"); } else if (!FileNameChecker.HasInvalidChar(fileName)) { string invalidChar = String.Empty; foreach (string s in FileNameChecker.InvalidCharList) { invalidChar += s + " "; } System.Windows.MessageBox.Show("A folder name cannot contain any of the following characters:\n" + invalidChar, "Invalid Folder Name"); } else if (FileNameChecker.IsLongName(fileName)) { System.Windows.MessageBox.Show("Folder name is too long.", "Invalid Folder Name"); } else if (fileName == String.Empty) { System.Windows.MessageBox.Show("You must type a folder name.", "Invalid Folder Name"); } else { DialogResult = true; } } else { string fileFullPath = filePath + fileName + fileExt; if (System.IO.File.Exists(fileFullPath)) { System.Windows.MessageBox.Show("There is already a file with the same name in this location.", "Invalid File Name"); } else if (!FileNameChecker.HasInvalidChar(fileName)) { string invalidChar = String.Empty; foreach (string s in FileNameChecker.InvalidCharList) { invalidChar += s + " "; } System.Windows.MessageBox.Show("A file name cannot contain any of the following characters:\n" + invalidChar, "Invalid File Name"); } else if (FileNameChecker.IsLongName(fileName)) { System.Windows.MessageBox.Show("File name is too long.", "Invalid File Name"); } else if (fileName == String.Empty) { System.Windows.MessageBox.Show("You must type a file name.", "Invalid File Name"); } else { DialogResult = true; } } }
public static string RenameShortcutName(string shortcutNameWithoutExt, string ext, string folderPath) { string shortcutName = FileNameChecker.Rename(shortcutNameWithoutExt, ext, folderPath); return(shortcutName); }