I have a variable with a path to a file I want to save and want to strip out any invalid characters that would cause the save or later move to fail. It worked fine for a batch but now failing again. I was going to remove the characters but for now just put a space in there. So here's an example:
- foreach (char c in System.IO.Path.GetInvalidFileNameChars())
- {
- item.Snippet.Title = item.Snippet.Title.Remove(c, ' ');
- }
So it's erroring on line 3 above wit error:
Unhandled Exception: System.ArgumentOutOfRangeException: Index and count must refer to a location within the string.
Parameter name: count
at System.String.Remove(Int32 startIndex, Int32 count)
at ShowWebsiteDownloader.Program.Main() in C:\Users\syarbrou.ICEO\source\repos\ShowWebsiteDownloader\ShowWebsiteDownloader\Program.cs:line 278
At the start of that loop item.Snippet.Title contains:
Disney Fort Wilderness Halloween Staycation Check In Day! | Cabin Tour, Holiday Decorations & BBQ!
Thoughts what's going on?