Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a block of code wrapped in an if:

mySite.AllowUnsafeUpdates();
SPFile mySPFile = web.GetFile(someURL);

if (mySPFile.Exists) /*returns true, enters code block*/ {
    //... make some updates
    mySPFile.Update(); //FAILS here, HRESULT 0x80070003 - File not found
}

If the file existed in the condition for the if, why can't it be found when I try to save the changes I made to its properties?

share|improve this question
    
We have a workaround: instead of going to the file (which is within a subsite) directly by URL, we are opening the containing subsite first and then accessing it by GUID. –  sq33G Jun 3 '12 at 11:31
add comment

1 Answer

I would recomand you read this article from Waldek concerning problems revolving with web.GetFile() available at http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/ and confront with your code, particularly when you passing a certain URL to the method.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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