I want to check Folder exits on Sharepoint Document Library.
I have a Document Library called Attachments
there are many Root Folders like this ( CMR_2000
, CMR_2001
)
as a example i want to check is CMR_2000
folder already exits on sharepoint document library ?
How can i do this ??
You can do it as follows
if (SPWeb.GetFolder(folderAbsoluteUrl).Exists)
{
//Folder Exisits
}
You can use this function:
public static bool CheckFolderExists(SPWeb web, string folderUrl)
{ try { return web.GetFolder(folderUrl).Exists; } catch (Exception ex) { return false; } }
Call it:
using (var web = new SPSite("http://site").OpenWeb()) { var folderExists= CheckFolderExists(web, "Attachments/CMR_2000"); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.