Показать сообщение отдельно
Старый 10.03.2010, 01:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
mscrmblog: SP - Uploading files to SharePoint document library
Источник: 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/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.