C#重载错误消息

时间:2011-08-04 17:01:56

标签: 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 = 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,我明白它在说什么,但我不知道为什么我会收到这个错误。有没有人有任何想法或建议的解决方案?所有反馈都表示赞赏。

1 个答案:

答案 0 :(得分:1)

客户端对象模型的Add方法只有一个参数: FileCreationInformation 。有关详细信息,请参阅此MSDN页面:http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.filecollection.add.aspx