using (SPSite objSite = new SPSite("urlAddress"))
{
objSite.AllowUnsafeUpdates = true;
{
objSite.AllowUnsafeUpdates = true;
using (SPWeb oSPWeb = objSite.OpenWeb())
{
oSPWeb.AllowUnsafeUpdates = true;
//Test1 is the document library
{
oSPWeb.AllowUnsafeUpdates = true;
//Test1 is the document library
SPList docLibrary = oSPWeb.Lists["Test1"];
using (FileStream fs = File.OpenRead(FullPath))
{
//Name is the name of the file
SPFile file = oSPWeb.Files.Add(oSPWeb.Url.ToString() + "/" + docLibrary.Title.ToString() + "/" + Name, fs);
file.Update();
}
{
//Name is the name of the file
SPFile file = oSPWeb.Files.Add(oSPWeb.Url.ToString() + "/" + docLibrary.Title.ToString() + "/" + Name, fs);
file.Update();
}
docLibrary.Update();
oSPWeb.AllowUnsafeUpdates = false;
}
}
objSite.AllowUnsafeUpdates = false;
}
}
No comments:
Post a Comment