• 删除列表中附件内容


    删除网站中列表里的附件内容   

         private static void DelectAttachmentAll()
            {
                SPSite site = new SPSite(siteUrl);
                SPWeb web = site.OpenWeb();
                try
                {
                    SPList list = web.Lists[listname];
                    for (int i = 0; i < list.ItemCount; i++)
                    {
                        SPListItem item = list.Items[i];
                        if (item.Attachments != null)
                        {
                            SPAttachmentCollection att = item.Attachments;
                            for (int j = 0; j < att.Count; j++)
                            {
                                try
                                {
                                    att.Delete(att[j]);
                                }
                                catch (Exception ex)
                                { }
                            }
                            item.Update();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
                finally
                {
                    web.Close();
                    web.Dispose();
                    site.Dispose();
                }
            }

  • 相关阅读:
    VS工具箱不显示DEV控件解决方法
    Win服务程序编写以及安装一般步骤
    cmd命令行带参启动程序
    C#递归拷贝文件夹下文件以及文件夹
    WPF中ComboBox控件绑定键值对操作
    MySQL学习(二)
    Mysql学习(一)
    XML学习(二)
    XML学习(一)
    关于Oracle本地连接出现与监听有关的问题的解决方法探讨
  • 原文地址:https://www.cnblogs.com/Anlycp/p/1267345.html
Copyright © 2020-2023  润新知