AGS.Editor.Utilities.DoesFileNameContainOnlyValidCharacters C# (CSharp) Метод

DoesFileNameContainOnlyValidCharacters() публичный статический Метод

public static DoesFileNameContainOnlyValidCharacters ( string fileName ) : bool
fileName string
Результат bool
        public static bool DoesFileNameContainOnlyValidCharacters(string fileName)
        {
            foreach (char c in fileName)
            {
                foreach (char invalidChar in Path.GetInvalidFileNameChars())
                {
                    if (invalidChar == c)
                    {
                        return false;
                    }
                }
            }
            return true;
        }

Usage Example

Пример #1
0
 public override bool NextButtonPressed()
 {
     if ((txtFileName.Text.Length > 0) &&
         (txtFriendlyName.Text.Length > 0) &&
         (txtCreateInFolder.Text.Length > 0))
     {
         if (!Utilities.DoesFileNameContainOnlyValidCharacters(txtFileName.Text))
         {
             Factory.GUIController.ShowMessage("The file name you have specified includes some invalid characters. Please use just letters and numbers.", MessageBoxIcon.Warning);
             return(false);
         }
         if (!VerifyPathContainsValidCharacters())
         {
             Factory.GUIController.ShowMessage("The folder name you have specified includes some invalid characters. Please use just letters and numbers.", MessageBoxIcon.Warning);
             return(false);
         }
         if (Directory.Exists(GetFullPath()))
         {
             Factory.GUIController.ShowMessage("The directory '" + GetFullPath() + "', already exists. Please choose another file name.", MessageBoxIcon.Warning);
             return(false);
         }
         return(true);
     }
     Factory.GUIController.ShowMessage("You must type in a file name and a game name to continue.", MessageBoxIcon.Information);
     return(false);
 }
All Usage Examples Of AGS.Editor.Utilities::DoesFileNameContainOnlyValidCharacters