简体   繁体   中英

How could i rename a file that is currently running in c#?

so basically I want to be able to rename the file application by itself without saying an error that the application is running so it can't rename it. is it possible?

One way to do this: lets say the actual exe is called file.exe

  • Have another program called file_launcher.exe - whose job is to check that file.exe and its own name (string before the underscore) is same
  • If not then it renames the file.exe appropriately
  • Then it starts the actual exe (using new name)
  • Actual exe when has to rename itself, actually renames the launcher file (updating the first part of name)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM