<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Sayed Ibrahim Hashimi - MSBuild, Web Deploy (MSDeploy), ASP.NET - diagnostic</title>
    <link>http://sedodream.com/</link>
    <description>MSBuild, C#, Visual Studio and more</description>
    <language>en-us</language>
    <copyright>Sayed Ibrahim Hashimi</copyright>
    <lastBuildDate>Sat, 05 May 2012 23:53:04 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>sayed.hashimi@gmail.com</managingEditor>
    <webMaster>sayed.hashimi@gmail.com</webMaster>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=fb09b691-0dce-4bf9-8db0-805e74bc0af2</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,fb09b691-0dce-4bf9-8db0-805e74bc0af2.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,fb09b691-0dce-4bf9-8db0-805e74bc0af2.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=fb09b691-0dce-4bf9-8db0-805e74bc0af2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Have you ever tried to perform an operation on a file (i.e. delete) just to be faced
with an error relating to the fact that an application is locking the file? This happens
to me a lot, including just now. I was writing some code and tried to switch branches
and was given the error below.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/image_4.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/image_thumb_1.png" width="903" height="51" />
          </a>
        </p>
        <p>
So I closed down Visual Studio as well as IIS Express as I figured those were the
ones which had the lock on the file, and tried again (a few times actually <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/wlEmoticon-smile_2.png" /> )
but continued to receive the error above. In order to determine which file had a handle
open to that file I downloaded <a href="http://technet.microsoft.com/en-us/sysinternals/bb896655" target="_blank">Handle</a> from
the <a href="http://technet.microsoft.com/en-us/sysinternals" target="_blank">sysinternals
suite</a>. (<em>I actually already had the items downloaded inside of a Dropbox share
which I use between multiple computers.</em>) I then executed the command handle.exe
nlog and the results are shown below. Note: I had to open a command prompt window
to run handle.exe, for some reason it wasn’t working from a PowerShell prompt.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/image_8.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/image_thumb_3.png" width="805" height="299" />
          </a>
        </p>
        <p>
As you can see there was a rogue devenv.exe process holding on to the file. After
killing the process I was able to proceed.
</p>
        <p>
Sayed Ibrahim Hashimi <a href="http://twitter.com/sayedihashimi" target="_blank">@SayedIHashimi</a></p>
      </body>
      <title>Windows how to determine what is locking a given file</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,fb09b691-0dce-4bf9-8db0-805e74bc0af2.aspx</guid>
      <link>http://sedodream.com/2012/05/05/WindowsHowToDetermineWhatIsLockingAGivenFile.aspx</link>
      <pubDate>Sat, 05 May 2012 23:53:04 GMT</pubDate>
      <description>&lt;p&gt;
Have you ever tried to perform an operation on a file (i.e. delete) just to be faced
with an error relating to the fact that an application is locking the file? This happens
to me a lot, including just now. I was writing some code and tried to switch branches
and was given the error below.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/image_4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/image_thumb_1.png" width="903" height="51" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
So I closed down Visual Studio as well as IIS Express as I figured those were the
ones which had the lock on the file, and tried again (a few times actually &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/wlEmoticon-smile_2.png" /&gt; )
but continued to receive the error above. In order to determine which file had a handle
open to that file I downloaded &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896655" target="_blank"&gt;Handle&lt;/a&gt; from
the &lt;a href="http://technet.microsoft.com/en-us/sysinternals" target="_blank"&gt;sysinternals
suite&lt;/a&gt;. (&lt;em&gt;I actually already had the items downloaded inside of a Dropbox share
which I use between multiple computers.&lt;/em&gt;) I then executed the command handle.exe
nlog and the results are shown below. Note: I had to open a command prompt window
to run handle.exe, for some reason it wasn’t working from a PowerShell prompt.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/image_8.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/Windows-Live-Writer/Windows-how-to-determine-what-is-locking_EB5D/image_thumb_3.png" width="805" height="299" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see there was a rogue devenv.exe process holding on to the file. After
killing the process I was able to proceed.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi &lt;a href="http://twitter.com/sayedihashimi" target="_blank"&gt;@SayedIHashimi&lt;/a&gt;
&lt;/p&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,fb09b691-0dce-4bf9-8db0-805e74bc0af2.aspx</comments>
      <category>diagnostic</category>
      <category>windows</category>
    </item>
  </channel>
</rss>