|
|
Danh hiệu: Administration
Nhóm: Administrators
Gia nhập: 23-07-2013(UTC) Bài viết: 6,102   Đến từ: Vietnam Cảm ơn: 10 lần Được cảm ơn: 2 lần trong 2 bài viết
|
Upload file to Sharepoint using client object model First add references to 'Microsoft.SharePoint.Client' and 'Microsoft.SharePoint.Client.Runtime' dll's. You can find them in 14\ISAPI folder if not in GAC. Help reference from: http://blogs.msdn.com/b/...-in-sharepoint-2010.aspx Mã:
using System;
using System.Linq;
using System.Collections.Generic;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using System.Net;
namespace UploadFileToSharePoint
{
class Program
{
static void Main(string[] args)
{
string webUrl = "https://server/siteCollection";
string folderUrl = "Shared%20Documents/MyF older/My Subfolder";
string sourceFolder = "c:/";
string fileName = "y.zip";
try
{
using (ClientContext context = new ClientContext(webUrl))
{
Web web = context.Web;
context.Load(web);
context.Credentials = new NetworkCredential("username", "P@ssw0rd", "domain");
Folder folder = context.Web.GetFolderByServerRelativeUrl(folderUrl);
context.Load(folder);
context.Load(folder.Files);
context.ExecuteQuery();
Console.WriteLine("Web Url: {0}", web.Title);
Console.WriteLine("Folder Name: {0}", folder.Name);
foreach (File file in folder.Files)
{
Console.WriteLine("File: {0}", file.Name);
}
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = System.IO.File.ReadAllBytes(sourceFolder + fileName);
newFile.Url = fileName;
Microsoft.SharePoint.Client.File uploadFile = folder.Files.Add(newFile);
context.Load(uploadFile);
context.ExecuteQuery();
Console.WriteLine("{0} file uploaded to: {1}", fileName, folderUrl);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Console.Read();
}
}
}
}
|
|
|
|
|
|
Upload file by FTP
(Utility Functions)
Bởi admin
07-12-2015 lúc 11:25:03(UTC)
|
Upload Files with FTP
(C#)
Bởi admin
21-11-2015 lúc 08:52:55(UTC)
|
Di chuyển
Bạn không thể tạo chủ đề mới trong diễn đàn này.
Bạn không thể trả lời chủ đề trong diễn đàn này.
Bạn không thể xóa bài của bạn trong diễn đàn này.
Bạn không thể sửa bài của bạn trong diễn đàn này.
Bạn không thể tạo bình chọn trong diễn đàn này.
Bạn không thể bỏ phiếu bình chọn trong diễn đàn này.