Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8127197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:26:28+00:00 2026-06-06T07:26:28+00:00

We have an ascx custom control (not a web part) hosted in a special

  • 0

We have an ascx custom control (not a web part) hosted in a special Sharepoint page. This page allows users to upload files to our server. Unfortunately permission issues are preventing Sharepoint from saving files to the network location.

The network account attributed to the application pool for the Sharepoint 2007 based site has “modify” and “read” access granted to the location.

We’ve logged in to a different machine using the credentials used by the application pool account and can create directories and files without any issue at the specified network location.

Is it possible Sharepoint is trying to use some other account to save these files rather than the one set on it’s Application Pool in IIS7?

The error we’re getting:

Message: Access to the path ‘\opal\gwl\pictures\L36’ is denied.

Stack Trace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity) at System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity) at ECan.SharePoint.Web.Applications.MyECan_WaterMeterFormDatalogger.SavePhotos()

Exception Type: System.UnauthorizedAccessException

User: System Account

The code for the SavePhotos function in the ascx code behind file:

protected void SavePhotos()
{
    string wellNo = WellNo.Value;
    string epoWaterMeterID = EPO_WaterMeterID.Value;
    string dirRoot = ConfigurationManager.AppSettings["PhotoDir"];
    string map = wellNo.Substring(0, wellNo.IndexOf('/'));

    int photoSaveCount = 1;
    foreach (string filePath in Request.Files)
    {
        HttpPostedFile file = (HttpPostedFile)Request.Files[filePath];
        if (file.InputStream.Length > 0)
        {
            try
            {
                // Create dir if does not exist
                string dir = dirRoot + map;
                if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);

                // Save file
                file.SaveAs(dir + @"\" + wellNo.Replace('/', '_') + "-" + epoWaterMeterID.ToString() + "-" + photoSaveCount.ToString() + ".jpg");

                photoSaveCount++;
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
            }
        }
    }
}

Anyone have any ideas what the issue might be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:26:30+00:00Added an answer on June 6, 2026 at 7:26 am

    I think you have to call the SavePhotos with elevated privildges.
    Running the code with elevated priviledges will executes the specified method with Full Control rights even if the user does not otherwise have Full Control.

    See link:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges(v=office.12).aspx

    Please try the below code:

    protected void Button1_Click(object sender, EventArgs e)
    {
       SPSecurity.CodeToRunElevated elevatedGetSitesAndGroups = new SPSecurity.CodeToRunElevated(SavePhotos);
       SPSecurity.RunWithElevatedPrivileges(elevatedGetSitesAndGroups);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom ASCX control that is not visible in design mode in
I have an ASP.NET user control (.ascx file). In this user control I want
I have two instances of an Address.ascx control in an ASP.NET MVC page. <h1>Shipping
I have a page containing a control called PhoneInfo.ascx. PhoneInfo is dynamically created using
I have a radio button list control on my ascx page and have a
I have a question about creating and managing events inside an ascx custom web
currently I have a custom VirtualPathProvider in a Asp.net MVC web application. This VirtualPathProvider
If I have a custom user control (say, MyCustomControl.ascx) which contains a number of
I have a custom .ascx control and would like to set one of it's
I have a custom control in my mater page that represents a menu, let's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.