In this blog I will explain you how to remove blank spaces from filenames. There are scenarios where we have to deal with files but we want to remove blank spaces from the filenames. Below is the code snippet I have used regular expression to explain it.
static void Main(string args)
string testString = "This is test file name";
static string Replace(string str)
return System.Text.RegularExpressions.Regex.Replace(str, @"\s+", "");
It will give the output: Thisistestfilename
Happy Reading .!