Using RadAsyncUpload to add files to a Sharepoint document library?

2 posts, 0 answers
  1. Steve
    Steve avatar
    20 posts
    Member since:
    Jan 2011

    Posted 25 Jan 2011 Link to this post


    I'm working on a Sharepoint 2010 installation, and have had a bit of trouble using the ASyncUpload in a custom Visual WebPart.

    I can add files to the RadUploadTemp folder fine, and in fact any folder on the 80 hive, but as far as I can tell there is no way to upload into the 14 hive. Is this correct?

    In the past, I have used the standard ASP FileUploader, with an IO Stream to upload directly to the url of my Sharepoint Library, but this does not seem to work with the RAD Async Upload, I just get this error:

    'http://local-sharepoint/TestLibrary' is not a valid virtual path.

    If I browse to that URL normally it works fine, and works fine with a standard uplader.

    Any ideas what's going on here?

    Thanks for any help
  2. Steve
    Steve avatar
    20 posts
    Member since:
    Jan 2011

    Posted 26 Jan 2011 Link to this post

    OK, I've sorted this now.

    Sharepoint Libraries and their contents are stored in SQL, rather than acutally as physical files.

    I've put my code below in case it helps someone else, although I'm sure there's some stuff I could be doing better :)

    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" Skin="Windows7"
    <telerik:RadButton ID="RadButton1" runat="server" Skin="Windows7" Text="Upload"

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using System.IO;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web.Configuration;
    using Telerik.Web.UI;
    namespace uploaderTEST.VisualWebPart1
        public partial class VisualWebPart1UserControl : UserControl
            String fileToUpload = @"C:\inetpub\wwwroot\wss\VirtualDirectories\80\Photos\";
            String sharePointSite = "http://local-sharepoint/TestSite/";
            String documentLibraryName = "Photos";
            String file;

    protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
                fileToUpload += e.UploadResult.FileName;
                file = e.UploadResult.FileName;
    public void AddDoc()
                using (SPSite oSite = new SPSite(sharePointSite))
                    using (SPWeb oWeb = oSite.OpenWeb())
                        if (!System.IO.File.Exists(fileToUpload))
                            throw new FileNotFoundException("File not found.", fileToUpload);
                        SPFolder myLibrary = oWeb.Folders[documentLibraryName];
                        // Prepare to upload
                        Boolean replaceExistingFiles = true;
                        String fileName = file;
                        FileStream fileStream = File.OpenRead(fileToUpload);
                        // Upload document
                        SPFile spfile = myLibrary.Files.Add(fileName, fileStream, replaceExistingFiles);
                        // Commit
            protected void RadButton1_Click(object sender, EventArgs e)

Back to Top