Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 从QuickLaunch中删除所有节点_Sharepoint_Sharepoint 2013_Comexception - Fatal编程技术网

Sharepoint 从QuickLaunch中删除所有节点

Sharepoint 从QuickLaunch中删除所有节点,sharepoint,sharepoint-2013,comexception,Sharepoint,Sharepoint 2013,Comexception,这是我删除QuickLaunch导航节点的代码。 我正在使用SharePoint 2013 public void 2013NodeOrders(string siteUrl, string quickLaunch) { SPSecurity.RunWithElevatedPrivileges(() => {

这是我删除QuickLaunch导航节点的代码。 我正在使用SharePoint 2013

                public void 2013NodeOrders(string siteUrl, string quickLaunch)
            { 
            SPSecurity.RunWithElevatedPrivileges(() =>
                        {
                            using (var localWeb = new SPSite(siteUrl).OpenWeb())
                            {
                                try
                                {
                                    var ql = localWeb.Navigation.QuickLaunch;
                                    int count = 0;
                                    while (count++ < 10)
                                    {
                                        try
                                        {
                                            CleanUpAutoCreatedNodes(ql, nodeNames.ToArray());
                                            break;
                                        }
                                        catch (Exception ex)
                                        {}
                                    }
                                   localWeb.Update();
                                }
                                catch (Exception ex)
                                {
                                   Console.WriteLine("Error Occoured ", ex);
                                    throw ex;
                                }
                            }
                        });
            }

            private static void CleanUpAutoCreatedNodes(SPNavigationNodeCollection ql, string[] nodenames)
                    {
                        foreach (SPNavigationNode globalNode in ql)
                        {
                            if (Array.IndexOf(nodenames, globalNode.Title) == -1) 
                            {
                                if (globalNode.Children.Count > 0)
                                {
                                    foreach (SPNavigationNode childNode in globalNode.Children)
                                        childNode.Delete();
                                }
                                if (!globalNode.Title.Equals("Site Contents"))
                                    globalNode.Delete();
                            }
                        }
                    }

您是否知道可以从SharePoint designer中删除导航节点

Stacktrace Error 

   at Microsoft.SharePoint.Library.SPRequestInternalClass.GetNavigationNodeChild(String bstrUrl, Int32 lParentId, Int32 lIndex, Int32& lNodeId, String& pbstrNodeUrl, String& pbstrName, String& pbstrNameResource, String& pbstrDateModified, Int32& pbIsVisible, Int32& pbIsExternal, Int32& plNumChildren, Guid& pgScopeId, Int32& plParentObjectType)
   at Microsoft.SharePoint.Library.SPRequest.GetNavigationNodeChild(String bstrUrl, Int32 lParentId, Int32 lIndex, Int32& lNodeId, String& pbstrNodeUrl, String& pbstrName, String& pbstrNameResource, String& pbstrDateModified, Int32& pbIsVisible, Int32& pbIsExternal, Int32& plNumChildren, Guid& pgScopeId, Int32& plParentObjectType)