Question find drive letter of a folder?

k0081

Member
Joined
Aug 25, 2021
Messages
18
Programming Experience
1-3
Hello to everyone

How can I get the drive letter installed in the system with the "Dx05" folder in a variable?
 
What is the type of the variable?
 
Then there is not enough information given just that string. You will have to iterate over each drive on the machine, and search to see if the folder with that name is somewhere on the drive. If it is, then, viola, you know which drive it is on.

If the type were Directory or DirectoryInfo, you could interrogate the class for it's other properties to determine the drive. Off the top off my head, the most direct way seems to be to ask for the full path, and then get the first letter of the full path to get the drive letter (assuming the full path does not contain a UNC path).
 
Dx05 is a folder and yes I know which drive it is on. But the system needs to find it.

and this folder is in the root of any ornament...
 
So you're saying that you want to test each drive on the system to see whether it has a folder with that name in the root folder? Please take the time and make the effort to provide a FULL and CLEAR explanation of the problem. You seem to be trying to get away with providing as little information as possible. Assume that too much is better than not enough.
 
So you're saying that you want to test each drive on the system to see whether it has a folder with that name in the root folder? Please take the time and make the effort to provide a FULL and CLEAR explanation of the problem. You seem to be trying to get away with providing as little information as possible. Assume that too much is better than not enough.
Yes, your first understanding is correct. Isn't this very simple? How clear should this be?
 
The task is simple enough but your initial description was incomplete and open to misinterpretation. It should be as clear as it possibly can be. As you can see from my post, it's not hard to describe requirements clearly without providing reams of information. It just takes a bit of thought.
 
With regards to the question, you should look at the DriveInfo class. That will provide a list of drives you can loop over and you can use Directory.Exists to see whether each drive contains that folder.
 
This is very simple but..

Is this how progress is being made in this forum now? ie spelling rules etc..

I think that going through the code will solve the problem very quickly.
 
Is this how progress is being made in this forum now? ie spelling rules etc..
No one has mentioned spelling so you seem to be making things up to feel aggrieved about. Consider the fact that you come here every now and again and ask a question but those of us who answer the questions are here every day, helping multiple people per day. Do you not think that it is reasonable for us to expect you to help us to help you by providing a clear explanation of your problem? Should we really have to spend our time trying to work out what problem we're actually being asked to help with before we can then provide that help? If people were considerate of those strangers on the internet whom they want to volunteer their time to help them then we wouldn't feel the need to point out that you could do a better job of asking for help.
 
I have never seen such a forum before. Are you with the problem? for solution?

Let's clear this up first.

If I knew the answer to the question I asked (which according to your statement, if I give so much detail, I will solve it myself..) why would I give it up?
 
Again, you're making up things to feel aggrieved about. I don't expect you to know the solution, e.g. I pointed out the DriveInfo class that you didn't know about and I didn't expect you to know about. What I do expect is for you to be able to provide a FULL and CLEAR explanation of the problem. Whatever you may think, you didn't do that. You can keep insisting that you did, learn nothing and continue posting poor questions in the future, thus reducing your chances of getting the help you want, or you can accept the fact that someone who has been answering questions on programming forums for 16 years knows a thing or two about what makes a good question and what doesn't, learn from that and do better in the future. The choice is yours. I will say no more on the matter.
 
I liked the forum and became a member. But extremely disappointing... I'm closing my membership.

Good Forums.
 
Back
Top Bottom