Ref:
http://mundeep.wordpress.com/2009/02/24/checking-if-a-spfolder-exists/
Posted by
mundeep on February 24, 2009
Ran into a colleague’s code that was incorrectly trying to check if a folder existed. It was something like:
1 | private bool CheckFolderExists(SPWeb parentWeb, string folderName) { |
2 | SPFolder folder = parentWeb.GetFolder(folderName); |
however this always returns an actual SPFolder object, and the correct way is to check the Exists property of the returned object ie:
1 | private bool CheckFolderExists(SPWeb parentWeb, string folderName) { |
2 | SPFolder folder = parentWeb.GetFolder(folderName); |
No hay comentarios:
Publicar un comentario