by
Mark Jones
| Dec 29, 2011
This example illustrates how to develop a helper method to return an SPFile based on a Web, folder and filename.
public static SPFile GetFile(SPWeb web, string folder, string fileName)
{
try
{ // get the folder in the web
SPFolder workingFolder = web.GetFolder(folder);
// get the file.
SPFile file = workingFolder.Files[fileName];
return file;
}
catch (Exception)
{ LogHelper.LogMethodEnd(logger, "SPFileHelper", "GetFile");
return null;
}
}