Jayesh
Jayesh

Reputation: 3951

Access Denied to any folder, C#

Getting this strange error.

In C#, I write to a file (txt) whose location I provide at run-time.

The problem is that whatever location I provide, It returns an error: Access to "..path.." is denied.

I checked the permissions, but the required permissions are set.

My code snippet

folderBrowserDialog.ShowDialog();

StreamWriter path = new StreamWriter(folderBrowserDialog.SelectedPath);
.
.
.

Any known issues or something I am missing?

Thanks

Upvotes: 1

Views: 1636

Answers (1)

Henrik
Henrik

Reputation: 23324

You should pass a file name to StreamWriter. It looks as if you're passing a folder name.

Upvotes: 8

Related Questions