Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Folder Permision During Setup

Status
Not open for further replies.

kafmil

Technical User
Jul 15, 2002
71
0
0
AU
I need to have some folders setup in the application folder of my program for logs and temp files. I need to be able to delete, edit and add files in these folders. The issue is that if the user is just a standard user they do not have appropriate permissions to be able to do this. Is it possible to get setup to automatically allow full control, or even just delete control to these folder during setup. The other issue is that the folders are always set to read only. I know I could use the users temp folder in Docs and Settings but i would really rather not, particularly for logs. If there is a way to do it in the application after setup that would be OK to.
Any help would be greatly appreciated.

Thanks
 
I can at least give you part of an answer. The setup project in VS (VS 2005 at least) cannot do this. Your choices are to use the User's Local Application Data folder, write back to a folder on a network share that the user has write access to, create your own setup program (not a setup project), or find/purchase a setup program that can do it.

-I hate Microsoft!
-Forever and always forward.
 
This kind of data should not really be in your application folder. It is better to place temporary files into the Temp folder and Log files into the Application Data directory.

The best way to create a temporary file is to use this function to create the file path:
Code:
System.IO.Path.GetTempFileName()

If you just need the directory you can use:
Code:
System.IO.Path.GetTempPath()

The application data directory is a little harder. You can get the base path by calling the following, but it is a convention to put your Company and Application on the end to avoid naming conflicts.
Code:
System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

As a result you will need to create this directory with the required permissions at install time. This can be done using an installer class. There is a C# example of how to do this half way down this thread, but it only works with .Net 2.0.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top