How can we valid and replace the special file name character with C# ?
I can found the Regex.Replace but what's the detailed pattern ?
Thanks for any help
How can we valid and replace the special file name character with C# ?
I can found the Regex.Replace but what's the detailed pattern ?
Thanks for any help
Hi @gh-2449 ,
Here is a demo for your reference to replace the special file name character using Regex.Replace:
const string pattern = "^(\\W|_vti|_)|[^\\w]|(files|file|Dateien|fichiers|bestanden|archivos|filer|tiedostot|pliki|soubory|elemei|ficheiros|arquivos|dosyalar|datoteke|fitxers|failid|fails|bylos|fajlovi|fitxategiak)$";
const string str = "Doc with & opr.docx";
var regexedStr = Regex.Replace(str, pattern, string.Empty);
Reference:
Thanks
Best Regards
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
4 people are following this question.