x86Debug
x86Debug

Reputation: 1

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?

Upvotes: 0

Views: 340

Answers (1)

Prateek Shrivastava
Prateek Shrivastava

Reputation: 1937

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)

Upvotes: 1

Related Questions