ここでハードコードされた設定の一部を変更する必要があります。
public void addToSharepointImageList(string folderName, string fileName, byte[] content)
{
string path = @"\\yoursite\yourlistname\";
string baseSharePointPath = "http://yoursite/";
string listName = "yourlistname";
SharePointImagingService.Imaging svc = null;
try
{
path += folderName;
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
#region create sharepoint service
svc = new SharePointImagingService.Imaging();
NetworkCredential nc = new NetworkCredential("username", "password", "domain");
svc.Credentials = nc;
//svc.Credentials = System.Net.CredentialCache.DefaultCredentials;
svc.Url = baseSharePointPath + listName+ "/_vti_bin/imaging.asmx";
svc.Discover();
#endregion
svc.Upload(baseSharePointPath + listName, folderName, content, fileName, true);
}
catch (Exception e)
{
//deal with error
}
finally
{
svc.Dispose();
}
}
または、ファイルをイメージ以外のリストに直接保存しようとしている場合は、共有ポイントを巨大なファイル共有として扱い、ファイルストリームを開いてそこにバイト配列を書き込むことができます。