I am trying to renaming every file’s empty space with an underscore:
DirectoryInfo dir = new DirectoryInfo(@"Q:\Audio");
var files = (from f in dir.GetFiles() select f.FullName);
files.ToList().ConvertAll( s => s.Replace( " ", "_") );
But it’s not working, I tried to use a foreach loop and it complains “Cannot assign to ‘element’ because it is a ‘foreach iteration variable'”
How do I approach this?
You can use one of code blocks below:
or:
or:
or (Bad Idea):
EDIT 1:
but i suggest to use select function, its better to not call .ToList() method for deferred objects like IQueryable.