Matt Paulson

Entrepreneur, Author, Private Equity Investor
  • Facebook
  • Linkedin
  • Twitter
  • Rss
  • Blog
    • Book Recommendations
    • Church Life & Ministry
    • Community Projects
    • Entrepreneurship
    • Quaterly Updates
    • Startup Community
    • Startup Q&A Show
    • Web Development
  • About
    • Resume
  • My Companies
    • Angel Investments
  • My Books
    • Online Business from Scratch
    • Automatic Income
    • The Ten-Year Turnaround
    • Email Marketing Demystified
    • 40 Rules for Internet Business Success
  • Media Appearances
  • Contact
Home» Web Development » How to Set File Permisisons to Upload Files in ASP.NET

How to Set File Permisisons to Upload Files in ASP.NET

Posted on May 21, 2009 by matt in Web Development No Comments
Tweet

If you plan on doing any sort of file manipulation on a web-server using ASP.NET, you’re going to have to become intimiately familiar with the System.IO library and learn how to properly configure the permissions for the directories you would like to write to on your Windows Server ’03 or ’08 web-server. Fortunately, the process isn’t terribly difficult.

If your permissions aren’t properly set, you’ll get an error like this when you try to upload a file in ASP.NET:

System.UnauthorizedAccessException: Access to the path 'C:\files\filename.ext' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at System.Net.WebClient.OpenFileInternal(Boolean needsHeaderAndBoundary, String fileName, FileStream& fs, Byte[]& buffer, Byte[]& formHeaderBytes, Byte[]& boundaryBytes)
at System.Net.WebClient.UploadFile(Uri address, String method, String fileName)
Class:EMLC_AddTopic;Method:FileUpload

Here’s how to configure the permissions your files and directories to upload files using ASP.NET:

(1) Logon to your web-server locally or using remote desktop.

(2) Browse to the folder you would like to be able to upload files to, right click it, and select properties.

properties

(3) Browse to the “Security” tab and select the “Network Service” account. If there’s no network service account present, click “Add” type in “Network Service” then click “Ok.”

uploads1

(4) To give ASP.NET the ability to upload files, Check the “Write” checkbox under Allow. To give ASP.NET the permissions to modify, rename and delete files in that directory, click “Modify.” Click “OK”, and it’s easy as that. If you continue to have problems, you might want to check your IIS settings and see if reading and writing files are disabled in there.

Tweet

Comments

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get Email Updates

Enter your email address below to receive a steady stream of tricks, tips and ideas to help you build a better and more profitable business.

Email Marketing Demystified

The second edition of Email Marketing Demystified is now available. This book teaches you how to build a massive email list, write marketing copy that converts and generate more sales in your business.

Click Here to Get Your Copy of Email Marketing Demystified

Recent Posts

  • Introducing MarketBrew, a Craft Beer from MarketBeat and Remedy Brewing Company

    April 22, 2021
  • How to Find and Pitch Investors for Your Startup

    April 13, 2021
  • My Quarterly Update: Q2 2021

    April 6, 2021
  • The Future of Seed-Stage Startup Capital in the Dakota’s

    March 31, 2021
  • Next Steps for Sioux Falls’ Startup Ecosystem

    March 16, 2021

    Follow me on Facebook & YouTube

    Contact

    • [email protected]
    • Contact Us
    • matthew-paulson
      • Facebook
      • Twitter
      • Linkedin
      • Instagram
      • Rss

    © Matthew Paulson 2003-2021. All Rights Reserved.

    Privacy Policy