Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Few questions about files

$
0
0

I am making a program that has this function:

User inputs a path of a specifigc file. 

Program checks if a "config.cfg" exists in that file.

If it doesn't you get error that it's wrong file.

Now program checks if there's file at program directory called "backup".

If it exists: It will copy the config.cfg to backup file.

If it doesn't exist it creates file "backup" at program directory and then copy the config.cfg to it.

My problem is that i get:

"UnauthorizedAccessException was unhandled"

Access to the path 'C:\Users\Guxi\Documents\Visual Studio 2010\Projects\Cworm\Cworm\bin\Debug\CWbackup' is denied.

This is the part of code where it happens:

string cdir = Directory.GetCurrentDirectory();
string backup_folder = cdir + @"\backup";File.Create(backup_folder);   // this causes error "unauthorizedAccesException"


How can i get the permission to access it?



Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>