<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Inconvenient SPWeb.GetFile(string)</title>
	<atom:link href="http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/</link>
	<description>Innovation Matters &#124; SharePoint Server MVP &#124; ISSN 2210-9390</description>
	<lastBuildDate>Wed, 08 Sep 2010 18:53:38 +0200</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Waldek Mastykarz</title>
		<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/comment-page-1/#comment-55242</link>
		<dc:creator>Waldek Mastykarz</dc:creator>
		<pubDate>Fri, 03 Sep 2010 15:00:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/2008/07/26/inconvenient-spwebgetfilestring/#comment-55242</guid>
		<description>@Robert: thanks for the feedback, Robert.</description>
		<content:encoded><![CDATA[<p>@Robert: thanks for the feedback, Robert.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Draeger</title>
		<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/comment-page-1/#comment-55237</link>
		<dc:creator>Robert Draeger</dc:creator>
		<pubDate>Fri, 03 Sep 2010 11:05:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/2008/07/26/inconvenient-spwebgetfilestring/#comment-55237</guid>
		<description>Hey Waldek,
I used to use the following construct:
SPWeb web = site.OpenWeb(fileUrl, false);
SPFile = web.getFile(fileUrl);
This has worked till today, where the filename contained an underscore (_myfile.jpg) - bad idea...

I tried your method now and got an \&quot;Incorrect function\&quot; exception on the first try, when using SPContext.Current.Site.RootWeb. It seems that you have to explicitly open your Web by using SPContext.Current.Site.OpenWeb(\&quot;/\&quot;). Pretty strange though, but now it works.

Cheers, Rob</description>
		<content:encoded><![CDATA[<p>Hey Waldek,<br />
I used to use the following construct:<br />
SPWeb web = site.OpenWeb(fileUrl, false);<br />
SPFile = web.getFile(fileUrl);<br />
This has worked till today, where the filename contained an underscore (_myfile.jpg) &#8211; bad idea&#8230;</p>
<p>I tried your method now and got an \&quot;Incorrect function\&quot; exception on the first try, when using SPContext.Current.Site.RootWeb. It seems that you have to explicitly open your Web by using SPContext.Current.Site.OpenWeb(\&quot;/\&quot;). Pretty strange though, but now it works.</p>
<p>Cheers, Rob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erdeniz S</title>
		<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/comment-page-1/#comment-48123</link>
		<dc:creator>Erdeniz S</dc:creator>
		<pubDate>Mon, 17 May 2010 15:29:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/2008/07/26/inconvenient-spwebgetfilestring/#comment-48123</guid>
		<description>Thank you for this article, you have just saved my day heheh :)

My problem was a bit different, with SPFolder.Files[url] property, it was finding the newly upload file just fine, but file&#039;s Item property was null. Same code was working on two other Document Libraries just fine with same security settings, permissions etc...</description>
		<content:encoded><![CDATA[<p>Thank you for this article, you have just saved my day heheh <img src='http://blog.mastykarz.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>My problem was a bit different, with SPFolder.Files[url] property, it was finding the newly upload file just fine, but file&#039;s Item property was null. Same code was working on two other Document Libraries just fine with same security settings, permissions etc&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: F. Aquino</title>
		<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/comment-page-1/#comment-38400</link>
		<dc:creator>F. Aquino</dc:creator>
		<pubDate>Fri, 25 Dec 2009 22:55:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/2008/07/26/inconvenient-spwebgetfilestring/#comment-38400</guid>
		<description>Hi Waldek, the post is a bit old but I wondered something in your &#039;obscure&#039; example (the 3rd one), site.RootWeb always gets the SPWeb that is also a SPSite (in your case, http://moss, independent of the level of URLs you sent to the constructor), wouldnt the http://moss/Pages/default.aspx exists also? 

Also, thanks for the alternate version, might come in handy</description>
		<content:encoded><![CDATA[<p>Hi Waldek, the post is a bit old but I wondered something in your &#039;obscure&#039; example (the 3rd one), site.RootWeb always gets the SPWeb that is also a SPSite (in your case, <a href="http://moss" rel="nofollow">http://moss</a>, independent of the level of URLs you sent to the constructor), wouldnt the <a href="http://moss/Pages/default.aspx" rel="nofollow">http://moss/Pages/default.aspx</a> exists also? </p>
<p>Also, thanks for the alternate version, might come in handy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Waldek Mastykarz</title>
		<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/comment-page-1/#comment-29819</link>
		<dc:creator>Waldek Mastykarz</dc:creator>
		<pubDate>Fri, 09 Oct 2009 04:34:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/2008/07/26/inconvenient-spwebgetfilestring/#comment-29819</guid>
		<description>@MJ: As far as I can remember, the above piece code worked correctly in my test.</description>
		<content:encoded><![CDATA[<p>@MJ: As far as I can remember, the above piece code worked correctly in my test.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MJ</title>
		<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/comment-page-1/#comment-29794</link>
		<dc:creator>MJ</dc:creator>
		<pubDate>Thu, 08 Oct 2009 23:49:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/2008/07/26/inconvenient-spwebgetfilestring/#comment-29794</guid>
		<description>Were you able to retrieve default.aspx using web.GetFileOrFolderObject(\\&quot;/site/subsite1/Pages/default.aspx\\&quot;)?

My problem is similar but in may case the file actually exists in the subsite but GetFileOrFolderObject() method is throwing exception.</description>
		<content:encoded><![CDATA[<p>Were you able to retrieve default.aspx using web.GetFileOrFolderObject(\\&amp;quot;/site/subsite1/Pages/default.aspx\\&amp;quot;)?</p>
<p>My problem is similar but in may case the file actually exists in the subsite but GetFileOrFolderObject() method is throwing exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Waldek Mastykarz</title>
		<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/comment-page-1/#comment-10529</link>
		<dc:creator>Waldek Mastykarz</dc:creator>
		<pubDate>Sat, 03 Jan 2009 18:33:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/2008/07/26/inconvenient-spwebgetfilestring/#comment-10529</guid>
		<description>@Donal: No it&#039;s not. It&#039;s being used to define an Extension Method. It&#039;s a .NET 3x feature but you can use it in .NET 2.0 with Visual Studio 2008 as well (more info @ http://geekswithblogs.net/robp/archive/2007/12/20/using-extension-methods-in-.net-2.0-with-visual-studio-2008.aspx)</description>
		<content:encoded><![CDATA[<p>@Donal: No it&#039;s not. It&#039;s being used to define an Extension Method. It&#039;s a .NET 3x feature but you can use it in .NET 2.0 with Visual Studio 2008 as well (more info @ <a href="http://geekswithblogs.net/robp/archive/2007/12/20/using-extension-methods-in-.net-2.0-with-visual-studio-2008.aspx)" rel="nofollow">http://geekswithblogs.net/robp/archive/2007/12/20/using-extension-methods-in-.net-2.0-with-visual-studio-2008.aspx)</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Donal</title>
		<link>http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/comment-page-1/#comment-10527</link>
		<dc:creator>Donal</dc:creator>
		<pubDate>Sat, 03 Jan 2009 17:52:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/2008/07/26/inconvenient-spwebgetfilestring/#comment-10527</guid>
		<description>I think the &#039;this&#039; is a typo in your method?

public static SPFile GetFileObject(this SPWeb web, string url)

Nice article though.  Saved me some trouble.</description>
		<content:encoded><![CDATA[<p>I think the &#039;this&#039; is a typo in your method?</p>
<p>public static SPFile GetFileObject(this SPWeb web, string url)</p>
<p>Nice article though.  Saved me some trouble.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
