We help IT Professionals succeed at work.

Overwriting a file in use

brettr
brettr asked
on
407 Views
Last Modified: 2013-12-16
Configuration: .NET 3.5, WPF app, C#

I'm running a WPF application from a network drive.  Multiple people use this app the same way.  I'd like to ovewrite the EXE when there is an update and once users restart the app, they are using the newer version.  I can't overwrite the file however becasue it is in use.   Is there some type of configuration to get around this?
Comment
Watch Question

Jaime OlivaresSoftware Architect
CERTIFIED EXPERT
Top Expert 2008

Commented:
it is an unusual situation, because executables use to be stored locally, even if them are network-related. If you store a copy in every station, you can solve this program with easy by giving it an auto-update feature.

Commented:
I've implemented a 'small' tcp-ip socket command listner, which  I use to send a command to. It then warns the user it't going to shutdown for an update, and shuts down. I use a little program to send this to the user, and just after send the shutdown broadcast (with authenticationcode ;-) it starts copying the files. This works wonderfully well. The user can restart his app a few seconds later...

Author

Commented:
Marcjev, that's basically what I was thinking of doing.  Can you post your code or possibly send it to me? brettrkr_at_gmail_dot_com.
Giuseppe 'Pino' De FrancescoSnr. Solutions Architect
CERTIFIED EXPERT

Commented:
Actually, if your file is precompiled (ngen) on the client you can overwrite the exe without fuss. Then you need to update the precompiled sw cache, this can be achieved simply using task manager.
Hope this helps
Cheers
Pino
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
PockyMaster, you are correct about this.   I've tested it successfully.  But how does that work?  If you can rename the file, then it is not locked right?  If it is not locked, you should be able to overwrite.
well, I guess it's just not locked for renaming, but locked for removal. I don't know the windows internals about this, just knows that it works :D
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.