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 6203909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:59:52+00:00 2026-05-24T04:59:52+00:00

I am trying to upload an image as an attachment in REST WCF Service

  • 0

I am trying to upload an image as an attachment in REST WCF Service and I am getting the following error.
“Access to path “C:\ImageUpload” is denied”
I have enabled Full Contorl permissions to this folder. I dont understand why I am getting this error.
I am new to WCF, and the most of the code I gathered from online resources.
Appreciate if you could let me know If there is any mistake in my code.
Here is my code.


REST WCF Service Code:

 [OperationContract]
 [WebInvoke(UriTemplate = "uploadImage/{parameter1}")]
  void uploadImage(Stream fileStream);

public void uploadImage(Stream fileStream)
        {
            string filePath = @"C:\ImageUpload";
            FileStream filetoUpload = new FileStream(filePath, FileMode.Create);

            byte[] byteArray = new byte[10000];
            int bytesRead, totalBytesRead = 0;

            do
            {
                bytesRead = fileStream.Read(byteArray, 0, byteArray.Length);
                totalBytesRead += bytesRead;
            }
            while (bytesRead > 0);
            filetoUpload.Write(byteArray, 0, byteArray.Length);
            filetoUpload.Close();
            filetoUpload.Dispose();
        }

This is my Test Client Code(Simple .aspx web page)

 protected void btnUpload_Click(object sender, EventArgs e)
        {
            string file = FileUpload1.FileName;
            RESTService1Client client = new RESTService1Client();

            byte[] bytearray = null;
            string name = "";
            if (FileUpload1.HasFile)
            {
                name = FileUpload1.FileName;
                Stream stream = FileUpload1.FileContent;
                stream.Seek(0, SeekOrigin.Begin);
                bytearray = new byte[stream.Length];
                int count = 0;
                while (count < stream.Length)
                {
                    bytearray[count++] = Convert.ToByte(stream.ReadByte());
                }
            }  
            WebClient wclient = new WebClient();
            wclient.Headers.Add("Content-Type", "image/jpeg");
            client.uploadImage(FileUpload1.FileContent);
}
  • 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-05-24T04:59:54+00:00Added an answer on May 24, 2026 at 4:59 am

    It’s likely nothing to do with WCF or your code. It really is highly probable that permissions on that folder are insufficient for the IIS process user. By default the ASP.NET user is Network Service.

    Try creating a new Windows user just for your ASP.NET application. Grant that user explicit read/write access to the upload folder. Then use Impersonation to make ASP.NET use that user.
    http://www.codeproject.com/Articles/107940/Back-to-Basic-ASP-NET-Runtime-Impersonation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Form I am trying to upload my image but every time
I have systematically an error when I'm trying to upload a file that is
I'm trying to upload an image file from an android device to my drupal
i am trying to upload an image from a jsp page using servlet. but
I am trying to upload an image to the server. I hava a form
I am trying to upload a image which i am clicking with the help
I am trying to upload an image from inside a JQuery modal. The form
i am having trouble trying to upload an image to a website, and update
Im struggling here for a lot, Im trying to upload an image from iphone
Trying to setup a personal image upload/downloader webpage. I've viewed the msdn article on

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.