Windows Directory path

Darren66

Member
Joined
Jun 9, 2003
Messages
20
I want to write a piece of code that creates a file in the windows directory when the user performs a certain action.
The problem I have is not creating the file but correctly referencing the windows path. What is the best way to do this?
Im hoping that there is something similar to Application.Path except for the windows directory..
If anyone can point me in the right direction it would be appreciated.
Thanks
 
Code:
Environment.SystemDirectory
returns the System32 directory, so you can use
Code:
System.IO.Directory.GetParent(Environment.SystemDirectory)
to retrieve it.

However, you should not create files in that directory unless you need to. What file are you creating?
 
I read a forum post here (I dont have the link to hand) which discussed the various methods for making an application inactive after 30 days if the user hasnt entered an unlock code. One method that was suggested was creating a hidden file in the windows directory which could be used to indicate whether the program was paid for or not, rather than using registry entries.

My intention was to do something similar...
 
I would recommend against that - creating files in the Windows directory without telling the user is not a good idea (at least in my opinion).

Plus, with a file-system monitor tool like FileMon, its easy to find out its location.

I suggest you just keep a heavily encrypted registry key that is rather difficult to break. Remember, 30-day trial versions are not really effective shareware, since it is generally fairly easy to reset the counter to 0, or even just uninstall and re-install your program. If you really want effective shareware, you need to actually remove functionality from the program.
 
Back
Top