BP Forums
Rename application file - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: Rename application file (/showthread.php?tid=815)



Rename application file - brco900033 - 10-12-2013

Hi

Is there a way of renaming the application file itself while it is running? I saw somewhere a code snippet to do it and I think it is possible but I can't remember how.


Re: Rename application file - brandonio21 - 10-12-2013

Well, if you're simply trying to rename the application file, using the FileSystem.Rename command.


You can use
[code2=vbnet]FileSystem.Rename(My.Application.ExecutablePath, "NewName.exe")[/code2]
--

I don't know if this will work while the application is running, but it's worth a shot!


Re: Rename application file - brco900033 - 10-14-2013

Haha, it worked. Didn't know that it would do that without giving an exception that the file is in use.

Thank you very much


Re: Rename application file - brandonio21 - 10-15-2013

brco900033 Wrote:Haha, it worked. Didn't know that it would do that without giving an exception that the file is in use.

Thank you very much

Wow, I honestly didn't expect it to either! Glad it worked!