20.1 Navigating with Windows Explorer
In order to make this book as helpful and self-contained as possible, we're going to include some information that many readers will already be familiar with. This section is a prime example of something you may already know: it's about how to look at files and directories in Windows. Feel free to skip it.
Windows Explorer is a tool for exploring the files and directories on your hard disk and on your local network. It has nothing to do with the bundled web browser that Microsoft calls Internet Explorer. The similarity of the two names may well have been part of the Microsoft strategy to tie Internet Explorer to the Windows operating system and 'cut off Netscape's air-supply,' as one Microsoft exec put it in the 1990s. Note also that the exact name 'Windows Explorer' varies among the different versions of Windows.
Opening Windows Explorer
When you left-click the Start menu you find on your Windows taskbar, you get a structured menu that has a partial listing of the programs that are on your machine. The Windows Explorer utility can be found under the Programs selection of the Start button. A common way to talk about this is to write a vertical to indicate a step down to a lower menu level. So what we're saying is that the utility we're looking for has a name like Start Programs Windows Explorer .
If you have a Microsoft-style keyboard with the special Windows Logo Key on it, you can very quickly open Windows Explorer by the key combination Windows Logo Key + E .
An alternate way to access Windows Explorer is to put a permanent shortcut for it on your desktop (or toolbar). You can do this by opening the Start Programs menu and right-dragging Windows Explorer to the desktop (or to the toolbar) and then choosing Create Shortcut Here from the context menu that pops up.
Viewing and opening directories and files
Anyway , once you start Windows Explorer, it opens up a Windows Directory window which may either be in the Classic Style view or the Web Style view; you can select between these on the View Folder Options General controls. You can also choose a mix of the two called Custom , and adjust this using the Settings dialog. You can really customize the Explorer view quite extensively. It takes a certain amount of playing with it to find the settings you like the best. Some more of these are under View Folder Options View menu of the Windows Explorer.
In any case, Windows Explorer will show you two panes: in the left will be a list of directories; on the right will be a list of the directories and files in the directory that's currently selected on the left. You use the left pane to navigate to the directory you are interested in.
The right pane shows the files in the directory, when they were last changed, and what their size is. That is, it will show all this information assuming that you check the Windows Explorer menu option View Details . You should also make sure that the box labeled Hide File Extensions for Known Types is not checked, as it is useful for a programmer to see the file extensions. This box will be in a submenu or dialog, depending on which version of Windows you have.
If you click on one of the files in the right window, Windows will try to 'open' the file. Traditionally a double-click was required. If you do a lot of programming, double-clicking can get quite tiring, even to the point of promoting repetitive stress disorder , so it's really worth avoiding having to do it. Explorer will be set so that a single-click activates a file or opens a directory if you are using the Web style view. If you are not using the Web style view, you can still open files with a single-click by selecting View Folder Options Custom Style and then clicking the Settings button to get to a dialog where you can choose single-click instead of double-click.
If the file is an executable, 'opening' it means running it, while if it is a text file it will be opened up in an application like WordPad. If the file is source code, Windows is likely to start a session of your compiler and open the file up inside of that. If Windows doesn't know what application to use to open the file, it will ask you what to do.
Copying directories and files
Windows Explorer is also useful for creating new directories. If you right-click in the right-hand part of the window you get a menu in which you can select New , and then you can select Directory and name the new directory. Or you can use the File New Directory selection from the Windows Explorer menu.
Note that you can repeatedly open Windows Explorer sessions (for instance by repeatedly pressing Windows Logo Key + E ), so that you can have several of these windows open. Generally it's convenient to keep one or several Windows Explorer sessions open at all times. You can minimize them into your task bar when not using them.
You can use the Explorer windows to move or to copy files. You can move a file by dragging it from one Explorer window to another. If you want to copy a file without removing it from the source directory, hold down the Ctrl key while you do the drag. A less stressful method is to select the files to copy or move and to then use the keyboard shortcuts Ctrl+C for copy or Ctrl+X for cut in the source directory, followed by Ctrl+V for paste in the target directory. There are other methods as well. For the sake of your body, you should try to learn to do what you want in the least physically stressful way.
Avoiding a Visual Studio gotcha
When you are working on a project, you should maintain an Explorer window that shows what is in the directory where you are keeping your source code. This is so you don't lose track of which files you are working on. Make sure you can see the time and date stamps for the files, and reassure yourself that these match the time and date when you are doing the changes.
In Microsoft Visual Studio the 'Solution Explorer' window (Workspace window in Version 6.0) does not show the directory paths of the files you are working on, so if you're not careful you can end up editing the wrong copy of a file, especially if there are several copies of the files with the same name.
If you open your files with the File Open File... dialog [which is just File Open... in Version 6.0], you will in fact see a directory path name in the top of the dialog, but it's quite easy to overlook this information. And it sometimes happens that when you ask Visual Studio to open a file it will by default go to the most recently used directory rather than to the directory where your active project lives.
One bad thing that can happen is that you keep changing code and the project keeps building without errors, but the behavior never changes: this is because you are editing files in a different directory from the directory you are building from.
A different bad thing that can happen is that, after working in Visual Studio for a while and closing it, you may think that the files you just worked on are in, say, C:\MyProject\Version1 , when in fact all along they were in J:\Program Files\Hidden\Bogus\ Version1 , and when you copy the files from the first directory to hand in for your homework or to share with a friend, you find you've copied the wrong thing.
As with most programming mistakes, everyone does this at least once. The secret of becoming an expert programmer is to grow and to learn, so that you don't make the same mistakes over and over again. And keeping an Explorer window open onto your project code helps make this error less likely.