Hi,

I've beeb playing around a bit with files and stuff to learn some of the aspects of C#. In order to not make it too convenient and easy I opted for using a String to hold my path, and then use DirectoryInfo to use it.

In one of the windows in my app I list all the folders inside the current folder. If you double click one of them, you enter the directory etc etc. My problem is with the first entry, which I made "..". How can I manipulate the string to point to the previous directory? And how can I check if I'm at the root?

Any help would be appreciated!

Cheers :)

It would probably be easiest if you just used a treeview...

Yup, I know. That's why I didn't want to use it :)

You can probably use something like an ArrayList and keep storing each and every path traversed there. So if you wanna go back, the last path stored will be the last visited and so on.

To check if you are at the root, you can check the number of "\" in the path string....

Yeah, that actually might work. All I'd have to do is split the String on "\\" :)

Cheers!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.