wsLists.AddAttachment(this.ListName, listItemID, safeFileName(attachment.Name), File.ReadAllBytes(attachment.FullName));
функция safeFileName =
private string safeFileName(string filename)
{
filename = filename.Replace(@"\", "");
filename = filename.Replace(@"/", "");
filename = filename.Replace(@":", "");
filename = filename.Replace(@"*", "");
filename = filename.Replace(@"?", "");
filename = filename.Replace(@"""", "");
filename = filename.Replace(@"<", "");
filename = filename.Replace(@">", "");
filename = filename.Replace(@"|", "");
filename = filename.Replace(@"#", "");
filename = filename.Replace(@"{", "");
filename = filename.Replace(@"}", "");
filename = filename.Replace(@"%", "");
filename = filename.Replace(@"~", "");
filename = filename.Replace(@"&", "");
return filename;
}