日期:2014-05-16  浏览次数:20597 次

sahrepoint 上次数据到文档库

sharepoint学习笔记汇总

http://blog.csdn.net/qq873113580/article/details/20390149

 

 protected void Button1_Click(object sender, EventArgs e)
        {
            
using (SPSite site = new SPSite("http://zhangyi:90"))
            {
                
using (SPWeb web = site.OpenWeb())
                {
                    web.AllowUnsafeUpdates 
= true;
                    Stream fStream 
= this.FileUpload1.PostedFile.InputStream;
                    
byte[] contents = new byte[fStream.Length];
                    fStream.Read(contents, 
0, (int)fStream.Length);
                    fStream.Close();
                    
string filename = FileUpload1.PostedFile.FileName;
                    
//filename = filename.Substring(filename.LastIndexOf("\\"));
                    web.Files.Add("http://zhangyi:90/DocLib1/test2.xml", contents, true);
                    Response.Write(
"OK"

);
                   
                }
            }