using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Microsoft.SharePoint;
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Microsoft.SharePoint;
namespace WebApplication4
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
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");
}
}
}
}
}