K. Weber
K. Weber

Reputation: 2773

IO.Directory.CreateDirectory() error

I'm installing an ASP.NET application (which works ok in local server) in a shared hosting and I get an exception in this point:

IO.Directory.CreateDirectory(the_path)

The exception is:

Error Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

The folder has (or should have) correct write permissions and in the hosting they don't say much, and, as I see here it could be related with MediumTrust environment...

Any ideas on how to face this? One solution could be (didn't try yet) place writable folders within virutal path directories, this is actually a security issue for my files, as they are actually exposed to anyone knowing the path.

Upvotes: 0

Views: 488

Answers (2)

SLaks
SLaks

Reputation: 887469

Your webhost has restricted .Net's ability to write to disk.

You can either ask them to change that, or write within your virtual directory and use Web.config to prevent public HTTP access.

Upvotes: 1

vcsjones
vcsjones

Reputation: 141638

I'm installing an ASP.NET application (which works ok in local server) in a shared hosting a

Shared Hosting typically runs in medium trust, so they don't give you permission to write to the file system outside of your application's directory. the_path needs to be inside of the root of your web application, and you must have write access to the file system.

You should contact your hosting provider to determine if you have writes to the file system.

Upvotes: 0

Related Questions