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

  • Home
  • SEARCH
  • 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 6158209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:55:08+00:00 2026-05-23T20:55:08+00:00

I am trying to do a file upload from Silverlight(Client Object Model) to Sharepoint

  • 0

I am trying to do a file upload from Silverlight(Client Object Model) to Sharepoint 2010 library.. Please see the code below..

        try{
            context = new ClientContext("http://deepu-pc/");
            web = context.Web;
            context.Load(web);
            OpenFileDialog oFileDialog = new OpenFileDialog();
            oFileDialog.FilterIndex = 1;
            oFileDialog.Multiselect = false;
            if (oFileDialog.ShowDialog().Value == true)
            {
                var localFile = new FileCreationInformation();
                localFile.Content = System.IO.File.ReadAllBytes(oFileDialog.File.FullName);
                localFile.Url = System.IO.Path.GetFileName(oFileDialog.File.Name);
                List docs = web.Lists.GetByTitle("Gallery");
                context.Load(docs);
                File file = docs.RootFolder.Files.Add(localFile);
                context.Load(file);
                context.ExecuteQueryAsync(OnSiteLoadSuccess, OnSiteLoadFailure);
            } 
        }
        catch (Exception exp)
        {
            MessageBox.Show(exp.ToString());
        }

But I am getting the following error

System.Security.SecurityException: File operation not permitted. Access to path '' is denied.
   at System.IO.FileSecurityState.EnsureState()
   at System.IO.FileSystemInfo.get_FullName()
   at ImageUploadSilverlight.MainPage.FileUpload_Click(Object sender, RoutedEventArgs e)

Any help would be appreciated

Thanks

Deepu

  • 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-23T20:55:09+00:00Added an answer on May 23, 2026 at 8:55 pm

    Silverlight runs with very restricted access to the client user’s filesystem. When using an open-file dialog, you can get the name of the selected file within its parent folder, the length of the file, and a stream from which to read the data in the file, but not much more than that. You can’t read the full path of the file selected, and you are getting the exception because you are attempting to do precisely that.

    If you want to read the entire content of the file into a byte array, you’ll have to replace the line

    localFile.Content = System.IO.File.ReadAllBytes(oFileDialog.File.FullName);
    

    with something like

    localFile.content = ReadFully(oFileDialog.File.OpenRead());
    

    The ReadFully method reads the entire content of a stream into a byte array. It’s not a standard Silverlight method; instead it
    is taken from this answer. (I gave this method a quick test on Silverlight, and it appears to work.)

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

Sidebar

Related Questions

I am trying to upload a CSV file to Oracle database from my client
im trying to use a file upload control from the obout control library, i
I am trying to do a file upload from gwt-ext without bringing up the
I'm trying to extend a form and add an upload file field from within
I am trying to upload a file from a flash widget to my rails
I am trying to find out how to upload a file from a web
I'm trying to upload a file via FTP from my local computer to an
I'm trying to upload a huge file from my Nokia N95 mobile to my
I'm trying to upload a file from a phonegap app on my blackberry device
I'm trying to implement file upload functionality in the iPhone app. Server code is

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.