I've got a program which looks for a previously-installed dependency. Unfortunately, it can be installed almost anywhere (including Program files or nested 6-7 levels deep in an arbitrary folder on C:/) with a couple of exceptions...
It should never be in the Windows or Users directories. Since these are usually quite large (and I've got no need to crawl user paths), I'd like to exclude them from the scan.
I know I can use Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
to get the path to the current user profile but is there a generic way to get the root users folder (C:\Users
on my machine)?
My working plan is to get the current user profile's parent folder but I'm unsure if there will be edge cases where this won't always give the correct result?