CompuServe Thread

Cur Dir Quiz?

5 messages in this thread
#79837From: Steve ShelleySep 29, 1994 8:11 AM
> For example, if I use the dialog to get to directory D:\SAMPLE, > then use the drive combo box to change to drive C:, then use it to > get back to D:, I want to return to directory D:\SAMPLE instead of > D: root. > > I've tried doing a SetCurrentDirectory() with just the drive "D:" > as well as "D:.". GetCurrentDirectory() always reports that I've > 'cd'd to the root. You probably need to use "D:\SAMPLE" or in general, the full directory name the user has asked you to 'move to'. "D:" or "D:." do nothing, they're just telling SetCurrentDirectory() to set drive D's directory to where it already is right now (which is probably the root by default). Stan Pensak – Intec Controls Corp. Read action !re ply Enter reply. (/EXIT when done) 1: But then my file dialog would need to keep a dynamic list 2: of the last-used drive oirectory on each drive. I doubt that 3: the Common Dialog does that, for example – how could it 4: keep a persistent list? ? There must be another way. 5: /post Message # 79842 posted
#79842From: SyndesisSep 29, 1994 10:17 AM
But then my file dialog would need to keep a dynamic list of the last-used directory on each drive. I doubt that the Common Dialog does that, for example – how could it keep a persistent list? There must be another way. There is 1 Reply. Read action !
#79905From: Steve ShelleySep 30, 1994 11:09 AM
> But then my file dialog would need to keep a dynamic list of the > last-used directory on each drive. I doubt that the Common Dialog > does that, for example – how could it keep a persistent list? > There must be another way. Oops, I don't think we're on the same wavelength here. Let's start from the beginning. Say the current drive is D: and the current directory is the root "\". Step 1: First call GetCurrentDirectory() to find out where you are NOW. Display this information to the user. You will display "D:\". Step 2: Now you want to fill up one dialog listbox with all the files there. Do this with the mask "*.*" with no drive or path specifier. The same calls to FindFirstFile and FindNextFile give you all the subdirectories, which you can drop into another listbox (I don't remember, but you may need to add ".." yourself.) Step 3A: Now say the user clicks on the SAMPLE directory in the subdirectory list box. Now, you call SetCurrentDirectory("SAMPLE"), and the current directory becomes D:\SAMPLE. Just go to back to step 1. Step 3B: Say the user clicks drive E: from your drives listbox instead. Just call SetCurrentDirectory("E:") and go to step 1 again. Current directory will probably become E:\. Step 4: If the user now clicks D:, just call SetCurrentDirectory("D:") and go to step 1 again. I am pretty sure, that because you were in the SAMPLE subdirectory LAST time you were on drive D:, you will be there again now. There is no need for YOU to remember in your code what the proper directory is for each drive letter. The secret is to use RELATIVE paths for the calls to SetCurrentDirectory(), especially when switching from drive to drive. You may need to use "D:." rather than just "D:". My last message may have described this poorly in sake of brevity. I may have been confused with OS/2, which provides separate, handy, GetCurrentDrive and SetCurrentDrive functions, allowing you to move the current directory for any drive without actually <going there> (Like typing 'cd d:\sample' on the command line while you are still on drive C:.) If I have misrepresented how SetCurrentDirectory() works, please jump in anyone! Stan Pensak Read action !re 79905 Enter reply. (/EXIT when done) 1: You have described exactly what I tried. However, specifying 2: either "DC:D:" or "D:." does not give the desired result of 3: "remembering" the current directory on the drive. It 4: really changes to root every time, as far as I can tell. 5: (Trying "D:\" does change to root, too. 🙂 ) 6: /post Message # 79929 posted
#79929From: SyndesisSep 30, 1994 2:26 PM
You have described exactly what I tried. However, specifying either "D:" or "D:." does not give the desired result of "remembering" the current directory on the drive. It really changes to root every time, as far as I can tell. (Trying "D:\" does change to root, too. 🙂 ) Read action !
#80032From: Steve ShelleyOct 3, 1994 11:11 AM
> You have described exactly what I tried. However, specifying > either "D:" or "D:." does not give the desired result of > remembering" the current directory on the drive. It really > changes to root every time, as far as I can tell. (Trying "D:\" > does change to root, too. 🙂 ) Well I'll be! I just tried our application. Sure enough, it forgets the current directory of each drive I visited. OK, sounds like time for someone from MS to explain how to do this, or at least how the Common Dialog does it! Stan Read action !