I am unable to pass a string value into my SPWeb.GetFolder
despite my input being a string
value.
private static void UploadEmlToSp(string sharePointSite, string sharePointDocLib, string emlFullPath, string requestNo)
{
using (SPSite oSite = new SPSite(sharePointSite))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
if (!System.IO.File.Exists(emlFullPath))
throw new FileNotFoundException("File not found.", emlFullPath);
SPFolder myLibrary = oWeb.Folders[sharePointDocLib];
if (SPWeb.GetFolder(requestNo).Exists) <--errored
{
//Folder Exisits
}
May I know what have I missed? Below is the error message.
An object reference is required for the non-static field, method, or property SPWeb.GetFolder(string)
You are calling an instance method like a static method. Just use the instance of
SPWeb
you have inoWeb
Static Classes and Static Class Members (C# Programming Guide)