TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John Riker
NA
85
15.8k
GetInvalidFileNameChars or part of the loop erroring
Nov 7 2020 8:47 AM
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?
Reply
Answers (
4
)
CSharp To Define a method which returns the next multiple of 100 for t
Data gridview operations