Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

I'm 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

  • *Experts*
Posted

Environment.SystemDirectory

returns the System32 directory, so you can use

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?

Posted

I read a forum post here (I don't have the link to hand) which discussed the various methods for making an application inactive after 30 days if the user hasn't 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...

  • *Experts*
Posted

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, it's 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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...