Obtain name of selected folder and subfolders

N

Noemi

Hi

I am really stuck and have gone around in ciricles.

I have code which once a button is clicked will request the user to select a
folder.

What I cannot work out is how to add the path to a string but only from the
selected folder and any sub-folders after the selected folder.

I dont want to see any of the folders which are above the selected folder.

Thanks
Noemi
 
D

Daniel Pineault

I'm not sure if I'm getting this right but, assuming you know the base
directory and your simply trying to extract the subdirectory(ies) selection,
something like the following should work

path = "c:\temp\subfolder1\subfolder2\"
path2 = "c:\temp\subfolder1\subfolder2\subfolder3\subfolder4\"
DeltaPath = right(path2,len(path2)-len(path))

If this isn't what you're after, can you re-explain please.
 
N

Noemi

Thanks Daniel

I am trying to understand what you have suggested.

So you are saying that if I use the folder user has selected, which we come
out as path = "C:\temp\subfolder1\subfolder2\"(with subfolder 2 being the
selected folder in this case.

and path2 would be showing all folders including the files

while deltapath would show as subfolder2\subfolder3\subfolder4\test.tif

because this is what I need but I am not sue if I have read it correct.

Thanks
Noemi
 
D

Daniel Pineault

Yes.

Basically asumming your base folder is "c:\database\images\" (I called this
path)

and your user is allowed to select a file and selects
"c:\database\images\productx\front.tif" (I called this path2)

then the DeltaPath would be "productx\front.tif"

and you can simply get this by substracting the 2 string lengths.

right(path2, len(path2)-len(path1))

this say return me the (37-19=) 18 rightmost characters of path2, therefore
"productx\front.tif"
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top