Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding 'root' of a path 1

Status
Not open for further replies.

Jerim65

Technical User
Aug 8, 2010
99
AU
I have saved a path such as

P:\My Documents\App Reports\CSV\.

Is there a neat way to get P:\My Documents\App Reports\

from this?

Thanks

Coldan


 
Coldan,

What exactly are you asking?

Do you need to extract the path from the filename? If so, you need JUSTPATH().

Or are you trying to get the path to one of the "special" folders, like MyDocuments?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike,

I'll try a longer description ;

My app trawls through a chosen folder and records which of the files therein are not used in the 3rd party application I write for.

So first time round the user chooses a folder and gets the report - he's happy.

Next time he wants to try another folder on the same 'tree' starting with the root ( found from the previously recorded folder.

As it stands he has to navigate all the way down from 'Desktop' to get to where he wants to choose the next folder.

So in my example,

the tree is

P:\My Documents\App Reports\CSV\
P:\My Documents\App Reports\LOG\
P:\My Documents\App Reports\WORD\

having got the list from the CSV folder he now wants to get it from the WORD folder ( without all the scrolling in the control that I have just written about in the other thread).

So I want to get the 'root' of the first folder as a start point

I am using an ini in which the first folder path is recorded

so I have


mysearchpath = readpwini(inifile,'read','Paths','SearchPath')
mysearchroot = ADDBS(JUSTPATH(SUBSTR(mysearchpath,1,LEN(mysearchpath)-1)))

I thought there might be a better way...

Coldan
 
Hi Coldan.

You can use FULLPATH('..\', mysearchpath). Unfortunately, it converts the entire path to upper case, but that's only an issue if you display it to the user.

Doug
 
Coldan,

Maybe something like this:

Code:
IF RIGHT(MySearchPath, 1) = "\"
  MySearchPath = LEFT(MySearchPath, LEN(MySearchPath) - 1)
ENDIF
MySearchRoot = JUSTPATH(MySearchPath)

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
parentFolder = FULLPATH(ADDBS(mysearchpath)+'..\')

Cetin Basoz
MS Foxpro MVP, MCP
 
If I understand correctly it sounds like you can do this by using the SET PATH command.

Let me assume the file naviagion starts with a click of a button or other event with a click.

lcCurrentPath = PATH()
SET PATH TO 'P:\My Documents\App Reports\

* do your thing

SET PATH TO (lcCurrentPath)

This is just and idea without knowing exactly what you are doing, but I think you get the idea..

Jim
 
Oops. I used set PATH. I believe it should have been SET DEFAULT for the example I provided...

Brain dead again.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top