Will this work or break if fileUrl is blank or does not even exists?

SPFile file = web. GetFile (fileUrl); 

if (file == null)

1 Answer 1


Use the exists property instead of null, GetFile method doesn't return null if file doesn't exist

SPFile file = web.GetFile(fileurl);

    //code here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.