How can I delete a "FolderName" item from directoryPaths array? Not physically from the path, only from directoryPaths.
string[] directoryPaths = Directory.GetDirectories(@path);
You can do this change in place by finding the element that you wish to delete (say, at index del), move all elements after del down by one index, and then resize the array down by calling Array.Resize:
int del = Array.IndexOf(directoryPaths, @path+"\\Desktop Files"); // Pick an index to delete
for (int i = del+1 ; i != directoryPaths.Length ; i++) {
directoryPaths[i-1] = directoryPaths[i];
}
Array.Resize(directoryPaths.Length-1);
IndexOf method to find the index (see the edit).IndexOf as the second parameter.using System.Linq;
var paths = directoryPaths
.Where(p => p != folderName)
.ToArray();
var directoryPaths = directoryPathsx .Where(p => p != @path + "\\Desktop Files") .ToArray();