G
GregMa
Does anyone have a good regex expression to replace any invalid filename
characters in a string? Those characters are:
/, \, :, *, ?, ", <, >, |
I have it right now with string.replace for each individual character,
but would like to do it all in one step if possible. Here's what I have
now:
title = title.Replace("?", "");
title = title.Replace(":", "");
title = title.Replace("\\", "");
title = title.Replace("/", "");
title = title.Replace("*", "");
title = title.Replace("\"", "");
title = title.Replace("<", "");
title = title.Replace(">", "");
title = title.Replace("|", "");
newFileName += title + targetFile.Extension;
targetFile.MoveTo(newFileName);
Thanks!
Greg
characters in a string? Those characters are:
/, \, :, *, ?, ", <, >, |
I have it right now with string.replace for each individual character,
but would like to do it all in one step if possible. Here's what I have
now:
title = title.Replace("?", "");
title = title.Replace(":", "");
title = title.Replace("\\", "");
title = title.Replace("/", "");
title = title.Replace("*", "");
title = title.Replace("\"", "");
title = title.Replace("<", "");
title = title.Replace(">", "");
title = title.Replace("|", "");
newFileName += title + targetFile.Extension;
targetFile.MoveTo(newFileName);
Thanks!
Greg