An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll : Access to the path ... is denied

Viewed 48076

I am trying to write a file to a directory that exists and is created by me in G:\\ i.e. not a system directory or in root drive like this

File.WriteAllBytes(directoryPath.Replace("wav", "mp3"), asBytesArray);

But this is throwing me this exception:

An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll    
Additional information: Access to the path 'G:\Song' is denied.

How can i solve this issue? Please help!

This is coming while I am debugging from Visual Studio and i am not sure how to give administrative rights to the application which is being run as a debug

2 Answers
Related