Overwrite file in use

  • Thread starter Thread starter Gene Vangampelaere
  • Start date Start date
G

Gene Vangampelaere

Hi,

I need to write a function that can replace some (.dll) files. That's easy
to do but what if there are some files in use ? How can I replace those
files ? is there a method to 'force' an overwrite ?
 
Gene Vangampelaere said:
I need to write a function that can replace some (.dll) files. That's easy
to do but what if there are some files in use ? How can I replace those
files ? is there a method to 'force' an overwrite ?

The only way I can think of is using p/invoke to delay the operation until
the next reboot:

How To Move Files That Are Currently in Use
<URL:http://support.microsoft.com/?scid=kb;EN-US;140570>
 
Gene,
In addition to the other comments:

Are these .dll files in use by your app or another app. Is the app that
using them a .NET app?

If the .dll files are in use by a .NET app, then I understand you can use
the Shadow Copy Files feature of an AppDomain (which is what ASP.NET uses).

To enable Shadow Copy Files for an AppDomain you need to set the
AppDomainSetup.ShadowCopyFiles & AppDomainSetup.ShadowCopyDirectories
properties when creating a new AppDomain.

The following article should get you started:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp

Its in C#, however it should be easily converted to VB.NET.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top