Rename a locked file
-
This seems like a really simple question, but I can't find the answer anywhere else and I know someone in here has to have faced it before. At the commandline (at least on NT/2k/XP, which is all that matters in this question), you can rename a file which is currently locked using ren and the program holding the file will adjust, allowing you to put a new file in its place ready for later. If I try to do this using MoveFileEx then (not entirely surprisingly) it complains that the file is locked. I could open a new process and use the commandline, and I will if I have to, but if there's some way of convincing MoveFileEx or call something else to rename the file then I'd prefer not to have a DOS box flash up. Does anyone know if this is possible? Paul
-
This seems like a really simple question, but I can't find the answer anywhere else and I know someone in here has to have faced it before. At the commandline (at least on NT/2k/XP, which is all that matters in this question), you can rename a file which is currently locked using ren and the program holding the file will adjust, allowing you to put a new file in its place ready for later. If I try to do this using MoveFileEx then (not entirely surprisingly) it complains that the file is locked. I could open a new process and use the commandline, and I will if I have to, but if there's some way of convincing MoveFileEx or call something else to rename the file then I'd prefer not to have a DOS box flash up. Does anyone know if this is possible? Paul
Does
SHFileOperation()
work any better?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
This seems like a really simple question, but I can't find the answer anywhere else and I know someone in here has to have faced it before. At the commandline (at least on NT/2k/XP, which is all that matters in this question), you can rename a file which is currently locked using ren and the program holding the file will adjust, allowing you to put a new file in its place ready for later. If I try to do this using MoveFileEx then (not entirely surprisingly) it complains that the file is locked. I could open a new process and use the commandline, and I will if I have to, but if there's some way of convincing MoveFileEx or call something else to rename the file then I'd prefer not to have a DOS box flash up. Does anyone know if this is possible? Paul
have a look at
ShFileOperation
I think it works for locked files.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
have a look at
ShFileOperation
I think it works for locked files.
Maximilien Lincourt Your Head A Splode - Strong Bad
You guys rock, thanks. Serious brain freeze on my part. Paul