Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Real path
Message
From
04/01/2022 09:17:09
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
04/01/2022 09:08:32
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01683189
Message ID:
01683193
Views:
59
>>Is there any simpler way to get a real path of a file or folder, even if the path, to start from, contains unfortunately uppercased parts? Filesystem object doesn't even have such a function, it keeps the casing as was passed to it.
>>
>>The one way I know is to use the 3rd parameter to adir(), which means recursively checking each level of the path and then reassembling it. Not that I don't have the time to do it, now I have, and (even worse) I have a strong deja vu, I think I already wrote such a function once but can't remember what I called it...
>>
>>Still, is there a simpler way?
>
>FilesystemObject does not have a function but it has a property
>
>
>local filename, fso, x
>
>filename = upper('D:\tmp\NBB\2021\structure_be-fr-pfs-ci-2021-01-01.pdf')
>
>fso = CreateObject("Scripting.FileSystemObject")
>
>x= m.fso.GetFile(m.filename)
>?m.x.Path
>
>x = m.fso.Getfolder(justpath(m.filename))
>?m.x.Path
>
Nope, tried that first. Assume you have a folder "Q:\Pictures", and try
x = m.fso.Getfolder(justpath("q:\piCTUres"))

x.Path will be q:\piCTUres. Which is exactly what I wanted to avoid. Here's the result of half an hour of fiddling:
		Function fPath(tcF)
	Function fPath(tcF)
*[2022-01-04 14:45:18] ndragan - start with 2, assume no need to check the disk letter
	lcEndpath=Addbs(tcF)
	lnStart=2
	lcFajl=Left(lcEndpath, At("\", lcEndpath, 1))
	For i=lnStart To Occurs("\", lcEndpath)
		lcPartDir=Left(lcEndpath, At("\", lcEndpath, i)-1)
		If Adir(aa, lcPartDir, "DHS",1)=0
			lcFajl=""
			Exit
		Else
			lcFajl=Addbs(lcFajl)+aa[1]
		Endif
	Endfor
	Return lcFajl

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform