0

I'm planning a program that can add URL strings to the 'hosts' file found in the system/drivers/etc directory in order to prevent the user from accessing websites they aren't permitted to.

I was just wondering how to refer to a specific system folder, like the one below, in a way that would avoid hard coding the English names for the folders.

C:\Windows\System32\drivers\etc

I'm aware that you can use this to get the first bit (up to System32), but how would I create a universal reference to the 'etc' folder? I don't know if either 'driver' or 'etc' are present on a French or Spanish OS, say.

    Environment.GetFolderPath(Environment.SpecialFolder.System)

This question also extends to referencing the 'hosts' file in the 'etc' folder (how on earth does one ensure this is cross-linguistically compatible?). I'd really appreciate your help with this conundrum, I imagine I'm just not seeing the obvious...

Thanks

Will

2
  • This looks like a .NET call?
    – Myrtle
    Jan 17, 2013 at 13:39
  • 2
    The folder names of the operating system won't change with user language. It is safe to assume that it will always be located in /drivers/etc/.
    – Overv
    Jan 17, 2013 at 13:39

1 Answer 1

1

You don't need to be concerned about the directory structure inside the system folder, it's fixed. Just Path.Combine the system folder with driver and etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.