Reputation:
I've tried following code:
foreach (string item in strArr)
{
item.Replace(" ", "");
System.IO.Directory.CreateDirectory(foldercreationPATH.Text + "\\final\\" + item);
};
but it doesn't do anything. If I add return before item.Replace, then it throws errors:
Method must have a return type and return must not be followed by an object expression!
Thanks for help in advance!
Upvotes: 1
Views: 89
Reputation: 1133
You need to assign your variable with the new value.
item = item.Replace(" ", "");
Or just put the Replace inside the method.
System.IO.Directory.CreateDirectory(foldercreationPATH.Text + "\\final\\" + item.Replace(" ", ""));
Upvotes: 3