2009-05-08 2 views
3

다음과 같이 webclient와 공유 지점에 파일을 업로드 할 수 있습니다..NET 셰어 포인트 작성 디렉토리

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

답변

3

용어 "디렉토리"는기만이다. SharePoint 웹 서비스의 '디렉터리'구조는 SharePoint 데이터베이스에있는 가상 구조입니다. SharePoint 개체 모델에서 '디렉터리'가 어떤 개체인지 식별해야합니다. 예를 들어 http://sharepoint.domain.com/dir은 사이트에 SPFolders, SPLists, SPDocumentLibraries 등의 '디렉터리'를 가질 수있는 SPSite 일 수 있습니다.

So "존재하지 않는 디렉토리 만들기"를 사용하면 SharePoint 사이트 디렉토리 구조에서 WebClient를 사용할 수 없게됩니다. Windows SharePoint Services 개체 모델과 SharePoint Webservices의 두 가지 옵션이 있습니다.

제 생각에는 개체 모델을 사용하기가 더 쉽지만 SharePoint 서버와 동일한 서버에서 응용 프로그램을 실행해야합니다. Webservices는 더 많은 작업을하지만 원격으로 사용할 수 있습니다.

추가하려는 개체 (예 : SPFolder, SPSite, SPList, SPDocumentLibrary 등)를 식별해야합니다.

개체 모델이 Here에 위치해 있지만 웹 서비스를 사용하려면 다음과 같은 위치에서 그들에 액세스해야합니다 사용을위한 충분한 문서입니다 :

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 

을 나는 목록 또는 문서 작업 영역에보고 제안은 서비스 서비스.

희망이 있습니다.

+0

두 개의 캐치로 훌륭하게 작동했습니다. 1. 하위 사이트가있는 경우 올바른 위치에 폴더를 만들려고 URL에 포함시켜야합니다. 2. 한 번에 여러 수준을 만들 수없는 한 번에 하나의 새 디렉터리를 만들 수 있습니다 (예 : 새/하위/폴더) – CaffGeek