C#过载错误消息

C#过载错误消息,c#,sharepoint,new-operator,overloading,arguments,C#,Sharepoint,New Operator,Overloading,Arguments,因此,我一直在尝试使用下面的这段代码尝试将图像上载到SharePoint图像库 static NetworkCredential credentials = new NetworkCredential(username, password, domain); static ClientContext clientContext = new ClientContext(siteURL); static Web site = clientContext.Web; static List list =

因此,我一直在尝试使用下面的这段代码尝试将图像上载到SharePoint图像库

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))


编译器返回一个错误,表示“Add”方法有两个参数,没有重载,我理解它的意思,但我不知道为什么会出现这个错误。有人有任何想法或建议的解决方案吗?感谢所有反馈。

客户端对象模型的添加方法只有一个参数:文件创建信息。有关更多详细信息,请参阅此MSDN页面:

假设它是一个
SPList
,这应该可以工作。根据本页,有一个重载包含两个参数,一个字符串和一个字节数组。您确定这就是错误所在吗?抱歉,这就是问题所在,它不是类型
SPLIST
。目前,我无法访问服务器上的目录以使用microsoft.sharepoint.dll文件。因此,我试图找到另一种方法。我在我的原始代码中包含了一些附加变量。您的目标服务器是哪个版本?WSS 3.0还是SP 2010?您是否直接使用客户端SDK或某个web服务(如Lists.asmx)?