tags:

views:

56

answers:

2

hi,

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

A: 

It could be a setting in your .NET configuration.
Check Administrative Tools > Microsoft .NET 2.0 Framework Configuration.

Especially, if you run your application from a network folder, it may have limited permissions.

Xavier Poinas
+6  A: 

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

Henrik
Henrik is right. You should use an OpenFileDialog and the FileName property.
Xavier Poinas
OH!!! How silly can I be!Thanks Henrik!
James
@Jay - if the answer solves your problem please mark his answer by clicking on the empty checkmark.... it will improve your 'accept rate' and you'll get more responses to your questions in future.
Dal