add permission for a direcotry with


i have on a code written for server to add a few words to a text file, but i'm not able to execute this code. i get an error "the application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file."

how i can give permission for the entire directory (it's a private directory, secured by password) ,this is what my web.config file contain:


    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" />
    <customErrors mode="Off" />



Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
i have on a code written for server to add a few words to a text file, but i'm not able to execute this code do you mean you can't add more data to a text file? or that you cannot execute the text file?

You have to change the permissions on that folder (ntfs permissions)  and add the user that is the app pool identity and give it write permissions the normal permissions are only read/execute.
Robberbaron (robr)Commented:
i believe you can also add a 'Web.config' in a particular folder of your app. Scripts in that folder then run as the impersonated user

i have a folder named 'netw' in which i have ashx and aspx files that access an internal file share, not normally available to the asp pool identity
<?xml version="1.0"?>

      <identity impersonate="true" userName="MyDomain\SpecialAccessUser" password="soMeStr0ngPassWrd" />

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.