Link to home
Start Free TrialLog in
Avatar of brettr
brettr

asked on

Overwriting a file in use

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?
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

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.
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...
Avatar of brettr
brettr

ASKER

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.
Avatar of Giuseppe 'Pino' De Francesco
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
ASKER CERTIFIED SOLUTION
Avatar of PockyMaster
PockyMaster
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brettr

ASKER

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