当前位置: 首页>>代码示例>>C#>>正文


C# SPList.Delete方法代码示例

本文整理汇总了C#中SPList.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# SPList.Delete方法的具体用法?C# SPList.Delete怎么用?C# SPList.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPList的用法示例。


在下文中一共展示了SPList.Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteItemsAndList

        private static void DeleteItemsAndList(SPList list, SPWeb targetWeb)
        {
            StringBuilder deleteBatch = new StringBuilder();
            deleteBatch.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>");

            string mask = "<Method><SetList Scope=\"Request\">" + list.ID + "</SetList><SetVar Name=\"ID\">{0}</SetVar><SetVar Name=\"Cmd\">Delete</SetVar></Method>";
            foreach (SPListItem item in list.Items)
            {
                deleteBatch.Append(string.Format(mask, item.ID));
            }
            deleteBatch.Append("</Batch>");
            targetWeb.ProcessBatchData(deleteBatch.ToString());
            list.Delete();
        }
开发者ID:ThorstenHans,项目名称:DotNetRocks,代码行数:14,代码来源:ContentPackFeatureService.cs

示例2: Delete

        /// <summary>
        /// Deletes the specified list.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        internal static void Delete(SPList list, bool force)
        {
            if (list == null)
                throw new SPException("List not found.");

            if (!list.AllowDeletion && force)
            {
                list.AllowDeletion = true;
                list.Update();
            }
            else if (!list.AllowDeletion)
                throw new SPException("List cannot be deleted.  Try using the '-force' parameter to force the delete.");

            try
            {
                list.Delete();
            }
            catch (Exception)
            {
                if (force)
                {
                    using (SPSite site = new SPSite(list.ParentWeb.Site.ID))
                    {
                        Utilities.RunStsAdmOperation(
                            string.Format(" -o forcedeletelist -url \"{0}\"",
                                          site.MakeFullUrl(list.RootFolder.ServerRelativeUrl)), false);
                    }
                }
            }
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:35,代码来源:DeleteList.cs


注:本文中的SPList.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。