Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't my C# app create files in Windows 7?

Tags:

c#

windows-7

I have a C# app that creates a settings file for itself to store the current state of certain visual elements. This app works just fine on any machine that isn't running Windows 7, but on those machines we get an error that the settings file can't be created because the user doesn't have permission. Now, I could fix this issue by going to each computer, logging in as the administrator and giving the user read and write access on the program folder for the application that we've installed, but there has to be a better way.

It seems like in XP, you got write access on the folders you created by default, but that isn't the case anymore. Is there a setting I need in the setup package to make this work?

like image 559
Jonathan Beerhalter Avatar asked Apr 23 '10 15:04

Jonathan Beerhalter


People also ask

Why is my USB-C not working?

The device you connected to has new features for USB-C that the cable doesn't support. The device or dongle isn't connected to the correct USB-C port on your PC. The device or dongle is using an external hub or dock to connect to your PC. Too many other Alternate Mode devices or dongles are connected to your PC.

What do I do when my C drive is full?

Step 1: Open My Computer, right-click the C drive, and select "Properties". Step 2: Click the "Disk Cleanup" button in the disk properties window. Step 3: Select temporary files, log files, Recycle Bin, and other useless files that you want to delete and click "OK".

Why is C drive so full?

However, the major causes responsible for filling up of C drive are: Recycle Bin is full. Installation of multitude of applications and programs. Large files downloaded and stored in C drive.


1 Answers

The point is that you shouldn't be storing settings files in the program folder. Microsoft have advised against this for a long time, but started making things stricter with Vista IIRC.

Use Environment.SpecialFolders.ApplicationData (etc) to find the most appropriate place to put settings. Or use the .NET settings infrastructure which does this automatically for you.

like image 52
Jon Skeet Avatar answered Oct 22 '22 13:10

Jon Skeet