Home > Blogs > Blog Post

Code Sample : How to programmatically get an SPFile in SharePoint

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;
    }
 
}

Compliance using DocRead

DocRead logoDocRead for SharePoint can help you manage policy compliance by:

  • Targeting documents or policies at specific groups of users
  • Allowing a specific amount of time for users to confirm agreement 
  • Sending email reminders when policy compliance is overdue
  • Users self-certify that they have read and fully understood the policy details
  • Securely storing records of confirmed policy acceptance
  • Monitoring the user acceptance of policies via a reporting suite
  • Providing detailed reading reports and statistics
  • Report drill through to show who has not accepted the policy
  • Automatically sending historic compliance tasks and policies to new users when they are added to a group
  • Bringing policy compliance requests immediately to users attention when they log on

DocRead is simple to install and configure. It seamlessly integrates with SharePoint and can be added to any existing SharePoint site.

To find out more, visit the DocRead product site.


blog comments powered by Disqus