01-11-2023 06:43 AM
Hi, I am searching for a way to find the folder "above" the folder stated by DIAdem FILEDLGDIR.
So if the FILEDLGDIR is "C:\Data\Test1\Raw" I would like to get this path "C:\Data\Test1".
I guess I could search the path string from "right(FILEDLGDIR,i)" and delete everything until I find a "\" but isn't there a easier way to find the parent folder of a path?
Thanks in advance!
/Mikael
Solved! Go to Solution.
01-12-2023 12:48 AM
Hi Mike_77,
That's what you need to do in the end. Here is an example:
dim sPathLong, sPathShort
sPathLong = "C:\Data\Test1\Raw"
' maake sure that the last character is "\"
sPathLong = PathAddTrailingBackslash(sPathLong)
sPathShort = left(sPathLong, InStrRev(sPathLong, "\", len(sPathLong) - 1))
msgbox sPathLong & vbCRLF & sPathShort
Greetings
Walter
01-12-2023 03:17 AM
Thanks, the InStrRev-command was very good!
InStrRev(sPathLong, "\", len(sPathLong) - 1)
However, DIAdem did not like the PathAddTrailingBackslash(sPathLong)-command.
/Mikael
01-12-2023 03:41 AM
Which DIAdem version do you have?
Greetings
Walter
01-12-2023 04:09 AM
DIAdem 2012 at the moment but have version 2021 soon.
/Mikael
01-12-2023 05:13 AM
OK, DIAdem 2012 does not support this function, but 2021 does.
Greetings
Walter
01-16-2023 06:14 AM
Just use the filesystem object from VBscript:
Option Explicit
Dim fso,GetTheParent
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName("C:\Data\Test1")