Источник:
http://mscrmblog.net/2010/03/09/sp-u...ument-library/
==============
here we go, just some simple upload code that uploads documents into a document library.
It also checks if the same file exist in the destination library before upload.
SPSite site = new SPSite("http://mysharepointsite");SPWeb web = site.OpenWeb();web.AllowUnsafeUpdates = true; // i always add this in to prevent security errorsStream fStream = postedFile.InputStream;byte[] contents = new byte[fStream.Length];fStream.Read(contents, 0, (int)fStream.Length);fStream.Close();string newFilename = System.IO.Path.GetFileName(postedFile.FileName);SPFile fileExist = web.GetFile(destFolder + "/" + newFilename);if (fileExist.Exists){ Response.Write("
Error: A file exist with the same filename. Please Rename this File.
");}else{ web.GetFolder(destFolder).Files.Add(newFilename, contents); completed.Text = "
Successfully uploaded '" + filename + "' to: " + destFolder + "
";}
Источник:
http://mscrmblog.net/2010/03/09/sp-u...ument-library/