Hello,
say I have a path C:\SubFolder1\SubFolder2\SubFolder2
how can I easily move up? I am asking if there is a proper function in System.Directory or System.File or somewhere else that does the job? I looked at msdn but I just got overwhelmd.
I am doing it currently via manually parsing the string. So I was thinking maybe there is a better way.
System.IO.DirectoryInfo is what ur lookin for.
if you construct a DirectoryInfo object by doing something like…
dir = new DirectoryInfo(“C:\SomePath\Something\Folder”);
you can use the dir.Parent property (not method) to retrieve a DirectoryInfo object of that directory’s parent.
OR
you can just use the static Directory.GetParent function
Directory.GetParent(“C:\SomePath\Something\Folder”);
which should also return a DirectoryInfo type object (which you can use the .Name property to retrieve the actual string; i believe ToString will return this as well)
SO I had been using GetParent in the past, but now with Unity’s latest 3.2, I get a “System.IO.Directory” does not contain a definition for “GetParent”… has that been removed specifically? I can build in Visual Studio and it doesn’t cause an error, but building in Unity Editor does.
Thanks.