문제

다음과 같이 WebClient와 함께 SharePoint에 파일을 업로드 할 수 있습니다.

using (System.Net.WebClient webclient = new System.Net.WebClient())
{
    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(
                    Encryptor.Decrypt(ConfigurationManager.AppSettings["username"]),
                    Encryptor.Decrypt(ConfigurationManager.AppSettings["password"]),
                    ConfigurationManager.AppSettings["domain"]);
    webclient.Credentials = credentials;

    string path = Path.Combine("http://sharepoint.domain.com/dir", filename);
    webclient.UploadData(path, "PUT", fileBytes);
}

그러나 디렉토리가 존재하지 않으면 디렉토리를 만드는 방법을 모르겠습니다.

내가 어떻게 할 수 있는지 아이디어가 있습니까?

감사합니다, -c

도움이 되었습니까?

해결책

SharePoint 사이트의 "디렉토리"라는 용어는 기만적입니다. SharePoint 웹 서비스의 '디렉토리'구조는 SharePoint 데이터베이스에 위치한 가상 구조입니다. SharePoint 객체 모델의 객체를 식별해야합니다. '디렉토리'는 예를 들어 다음과 같습니다. http://sharepoint.domain.com/dir 아마도 사이트에 Spfolders, splist, spdocumentlibraries 등의 '디렉토리'를 가질 수 있습니다.

따라서 "존재하지 않는 디렉토리 만들기"라면 SharePoint 사이트 디렉토리 구조에서 의미가 있다면 WebClient와 관련이 없습니다. Windows SharePoint Services 객체 모델과 SharePoint 웹 서비스의 두 가지 옵션이 있습니다.

객체 모델은 내 의견으로는 확실히 사용하기 쉽지만 SharePoint 서버와 동일한 서버에서 앱을 실행해야합니다. 웹 서비스는 조금 더 많은 작업이지만 원격으로 사용할 수 있습니다.

추가하려는 객체 (예 : SPFolder, Spsite, Splist, Spdocumentlibrary Ect)를 식별해야합니다.

위치한 객체 모델을 사용하기위한 충분한 문서가 있습니다. 여기 그러나 웹 서비스를 사용하려면 다음 위치에서 웹 서비스에 액세스해야합니다.

Administration Service       http://<server-url:port-number>/_vti_adm/admin.asmx
Alerts Service               http://<server-url>/_vti_bin/alerts.asmx
Document Workspace Service   http://<server-url>/_vti_bin/dws.asmx
Forms Service                 http://<server-url>/_vti_bin/forms.asmx
Imaging Service             http://<server-url>/_vti_bin/imaging.asmx
List Data Retrieval Service http://<server-url>/_vti_bin/dspsts.asmx
Lists Service                 http://<server-url>/_vti_bin/lists.asmx
Meetings Service               http://<server-url>/_vti_bin/meetings.asmx
Permissions Service         http://<server-url>/_vti_bin/permissions.asmx
Site Data Service             http://<server-url>/_vti_bin/sitedata.asmx
Site Service                   http://<server-url>/_vti_bin/sites.asmx
Users and Groups Service       http://<server-url>/_vti_bin/usergroup.asmx
Versions Service               http://<server-url>/_vti_bin/versions.asmx
Views Service                 http://<server-url>/_vti_bin/views.asmx
Web Part Pages Service       http://<server-url>/_vti_bin/webpartpages.asmx
Webs Service                   http://<server-url>/_vti_bin/webs.asmx

목록이나 문서 작업 공간 서비스 서비스를 살펴 보는 것이 좋습니다.

도움이되기를 바랍니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top