I have the following code:
SPFolder oFolder = myList.RootFolder.SubFolders[folderName];
if (oFolder == null)
{
Console.WriteLine("FOLDER NOT FOUND");
}
else
{
Console.WriteLine("FOLDER FOUND");
}
Looks good on the surface but it only works if the folder exists, if the folder doesn't exist it throws an object reference not set to an instance error.
Is there a better way to check if a folder exists (without iterating through every folder in a collection?