Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How add file is document of sharepoint use the webpart

$
0
0

Hi all.

I want file upaload in sharepoint's document use my Webpart.

this is my source

protected void Button1_Click(object sender, EventArgs e)
        {
            using (SPSite site = new SPSite("http://nar-cla500s3:12345/sites/qa"))
            {
                using (SPWeb web = site.AllWebs[""])
                {
                    string filepath = @"C:\Users\lx13040020\Desktop\test.xlsx";            
                    FileStream filestream = File.OpenRead(filepath); <-- error access denied
                    SPFile file = web.Folders["QADocument"].Files.Add(filepath, filestream, true);                
                }
            }

But I have error "access denied".

I referd to this link

(SPFile ex)

http://stackoverflow.com/questions/468469/how-do-you-upload-a-file-to-a-document-library-in-sharepoint

(Filestream Access denied)

http://stackoverflow.com/questions/7706467/access-to-the-path-denied-error-in-c-sharp

But i could not solve my problem.

please teach me, Wait for your help. Thank you


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>