Delphi Programming

File rename or move from the project manager

2,918pages on
this wiki
Add New Page
Add New Page Talk0

The project manager window has been a feature of the Delphi IDEs for years, but only recently (I think it was with Delphi 2005) it has aquired a new feature: You can rename and even move files in it:

Just open an existing project of yours (to be safe: Make a copy and open that copy.) and bring up the project manager.

It will show you your project and all the files it contains.

Now select one of the files, let's say "MyForm1". Since this is a rather stupid name, we want to change it to "MyGreatForm" which sounds much better, doesn't it? You probably used "Save As" to do this until now, but there is now a much easier way: Just click on it again (alternatively press F2) and the name becomes editable, just like a file in Windows explorer. Change the name and press return.

Now, if you open an explorer window and look into your project's directory you will find, that not only was the .pas file renamed to "MyGreatForm.pas" but also the corresponding .dfm file. That's convenient, isn't it?

Unfortunately this is where the convenience ends: The IDE just ignores any existing .dcu files for your unit. This means that any references to the old name will still work and access your old form. Also, the IDE does not change these references, so you will have to do that yourself.

Ok, back to the things that it does:

You can also rename your project using the same technique. Delphi will again rename your .dpr file as well as the .bdsproj, .res and .cfg file which is also convenient. Unfortunately again it falls a bit short: It does not delete some of the old files, like .identcache and there is also still a copy of the old .cfg file. Still that feature is quite useful.

Last orders please! (If you happen to be young enough to have been to the UK and not know what this means, or never been to the UK at all: Until recently all pubs there had to close at 23:00 hours. To remind their customers that they were about to do that, the bartender used to ring a bell and call "Last orders please!" so everybody could get a last refill.)

What I wanted to say was, that I have mentioned moving a file as well. You can move a unit of your program to the directory above your project directory by prepending it with "..\". You can move it to an existing(!) subdirectory by prepending it with "subdirectory\". You can even combine this by prepending "..\otherprojectdir\". Again, the .dcu file will not be moved, so be aware that you might be using an old one if you don't explicitly use the correct path.

Also on Fandom

Random Wiki