Показать сообщение отдельно
Старый 09.02.2022, 08:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
How to validate filename with regular expressions
Источник: http://alexvoy.blogspot.com/2022/02/...h-regular.html
==============

I took the idea from this forum https://stackoverflow.com/questions/...-under-windows

We can use regular expressions to check if a given file name is valid.




///
/// Validates a filename for incorrect characters
///
///
///
public boolean checkFileName(Filename _fileName)
{
var bad = System.IO.Path::GetInvalidFileNameChars();
var esc = System.Text.RegularExpressions.Regex::Escape(new System.String(bad));
var exp = new System.Text.RegularExpressions.Regex("[" + esc + "]");

if (exp.IsMatch(_fileName))
{
return checkFailed(strFmt("@SYS339524")); // The specified filename is invalid.
}
return true;
}





Источник: http://alexvoy.blogspot.com/2022/02/...h-regular.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.