2011-08-04 8 views
0

그래서 아래 코드를 사용하여 이미지를 SharePoint 이미지 라이브러리에 업로드하려고했습니다. C# 오버로드 오류 메시지

static NetworkCredential credentials = new NetworkCredential(username, password, domain); 
static ClientContext clientContext = new ClientContext(siteURL); 
static Web site = clientContext.Web; 
static List list = site.Lists.GetByTitle("Site Images"); 

private static byte[] StreamFile(string filename) 
{ 
    FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); 
    // Create a byte array of file stream length 
    byte[] ImageData = new byte[fs.Length]; 
    //Read block of bytes from stream into the byte array 
    fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length)); 
    //Close the File Stream 
    fs.Close(); 
    return ImageData; 
} 


private static void uploadImage() 
{ 
    String fileName = "Sunset"; 
    String filePath = "C://Documents and Settings//Desktop//Sample Extracted Pic.jpeg"; 

    list.RootFolder.Files.Add(fileName, StreamFile(filePath)); 
} 

... 그리고 당신이 얻을 때까지 모든 것이 (적어도 컴파일러 내에서) 잘 보인다 list.RootFolder.Files.Add(fileName, StreamFile(fileName));

컴파일러는 No overload for method 'Add' takes 2 arguments 말하는 오류를 반환하고, 나는 무슨 말 이해하지만, 내가 가진 왜 내가 그 오류를 얻고 있는지 전혀 모르겠다. 누구든지 아이디어 나 제안 된 해결책이 있습니까? 모든 의견을 보내 주시면 감사하겠습니다.

+0

'list'는 어떤 유형입니까? –

+0

그것이'SPList'라고 가정하면, 이것은 효과가 있습니다. 이 페이지 http://msdn.microsoft.com/en-us/library/ms461726.aspx에 따르면 2 개의 인수, 1 개의 문자열 및 1 개의 바이트 배열을 사용하는 오버로드가 있습니다. 오류가 발생한 곳이 확실합니까? –

+0

죄송합니다. 문제가 있습니다. 유형이 'SPLIST'가 아닙니다. 이 순간 나는 서버의 디렉토리에 액세스하여 microsoft.sharepoint.dll 파일을 사용할 수 없습니다. 따라서 나는 대체 방법을 찾고있다. 원본 코드에 몇 가지 추가 변수가 포함되었습니다. –

답변