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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:55:59+00:00 2026-05-12T08:55:59+00:00

Hey, I’ve got this nice little piece of code, much like all the other

  • 0

Hey, I’ve got this nice little piece of code, much like all the other versions of this method of upload using WSS WebServices. I’ve got one major problem though – once I have uploaded a file into my doc list, and updated the list item to write a comment/description, the file is stuck there. What I mean is that this method will not overwrite the file once I’ve uploaded it. Nobody else out there seems to have posted this issue yet, so .. anyone?

I have another version of the method which uses a byte[] instead of a Stream .. same issue though.

Note: I have switched off the ‘require documents to be checked out before they can be edited’ option for the library. No luck tho .. The doc library does have versioning turned on though, with a major version being created for each update.

    private void UploadStream(string fullPath, Stream uploadStream)
    {
        WebRequest request = WebRequest.Create(fullPath);
        request.Credentials = CredentialCache.DefaultCredentials; // User must have 'Contributor' access to the document library
        request.Method = "PUT";
        request.Headers.Add("Overwrite", "t");

        byte[] buffer = new byte[4096];
        using (Stream stream = request.GetRequestStream())
        {
            for (int i = uploadStream.Read(buffer, 0, buffer.Length); i > 0; i = uploadStream.Read(buffer, 0, buffer.Length))
            {
                stream.Write(buffer, 0, i);
            }
        }
        WebResponse response = request.GetResponse(); // Upload the file
        response.Close();
    }

Original credits to: http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html

EDIT — major finding .. when I call it from my nUnit test project it works fine. It seems it only fails when I call it from my WCF application (nUnit running under logged on user account, WCF app has app pool running under that same user — my account, which also has valid permissions in SharePoint).

Nuts. “Now where to start?!”, I muses to myself.

  • 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-12T08:56:00+00:00Added an answer on May 12, 2026 at 8:56 am

    SOLVED — I found a little bug – the file was being created in the right place, but the update path was wrong.. I ended up finding a folder full of files with many, many new versions.. doh!

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

Sidebar

Related Questions

Hey I have following code like this public object RetrieveItemRun(int item) { if (dictionary.ContainsKey(item))
Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>
Hey all i am wondering why my code below is only writing the first
hey guys I have the follow code in js: $(document).ready(function(){ $(.replyLink).click(function(){ $(#form-to-+this.id).html(htmlForm()).toggle(500); return false;
Hey all i am wondering why i am getting this error with the following
Hey all, my Computational Science course this semester is entirely in Java. I was
hey guys having this really simple problem but cant seem to figure out have
Hey all i have a JSFiddle that i have been working on with trying
Hey basically i want both the player and the wolves to attack each other
Hey all i am trying to figure out what i am doing incorrectly here.

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.