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


C# SPFolder类代码示例

本文整理汇总了C#中SPFolder的典型用法代码示例。如果您正苦于以下问题:C# SPFolder类的具体用法?C# SPFolder怎么用?C# SPFolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: LoadFolderNodes

        protected void LoadFolderNodes(SPFolder folder, TreeNode folderNode)
        {
            foreach (SPFolder childFolder in folder.SubFolders)
            {
                TreeNode childFolderNode = new TreeNode(childFolder.Name, childFolder.Name, FOLDER_IMG);
                childFolderNode.NavigateUrl = SPContext.Current.Site.MakeFullUrl(childFolder.Url);
                LoadFolderNodes(childFolder, childFolderNode);
                folderNode.ChildNodes.Add(childFolderNode);
            }

            foreach (SPFile file in folder.Files)
            {
                TreeNode fileNode;
                if (file.CustomizedPageStatus == SPCustomizedPageStatus.Uncustomized)
                {
                    fileNode = new TreeNode(file.Name, file.Name, GHOSTED_FILE_IMG);
                }
                else
                {
                    fileNode = new TreeNode(file.Name, file.Name, UNGHOSTED_FILE_IMG);
                }

                fileNode.NavigateUrl = SPContext.Current.Site.MakeFullUrl(file.Url);
                folderNode.ChildNodes.Add(fileNode);
            }
        }
开发者ID:Helen1987,项目名称:edu,代码行数:26,代码来源:SiteExplorerUserControl.ascx.cs

示例2: CheckPathAndCreate

        private static string CheckPathAndCreate(string strExportPath, SPFolder folder)
        {
            string strPath;
            strPath = string.Format("{0}\\{1}", strExportPath, folder.Url.Replace("/", "\\"));
            //strPath = "d:\\Export\\IT\\IT\\Project\\Phase 2 - Rel 1 Implementation\\90-Team Folder\\Difei\\ARS\\ARS global documents\\FY06 ARS Process Model\\6 - Enterprise Management\\6.01 - Master Data Maintenance - Retail Organization\\6.1.03 CMD Company Code and Purchase Organiz\\test";
            if (!Directory.Exists(strPath))
            {
                try
                {
                    //if (strPath.ToCharArray().Length < 248)
                    //{
                    Directory.CreateDirectory(strPath);
                    //}
                }
                catch (PathTooLongException pathTooLongException) {
                    LogInfoToRecordFile(InfoLogUNCPath, string.Format("The specific folder <{0}> path {1} is too long!",
                                                                        folder.Url,
                                                                        strPath));

                    strPath = null;
                }
            }

            return strPath;
        }
开发者ID:porter1130,项目名称:MyTest,代码行数:25,代码来源:Program.cs

示例3: update_folder_time

 protected void update_folder_time(SPFolder current_folder)
 {
     if (current_folder == null || !current_folder.Url.Contains("/")) return;
     current_folder.SetProperty("Name", current_folder.Name);
     current_folder.Update();
     update_folder_time(current_folder.ParentFolder);
 }
开发者ID:ricardocarneiro,项目名称:SharePoint-1,代码行数:7,代码来源:Item+Changed+Event.cs

示例4: DeployWelcomePage

        private void DeployWelcomePage(object modelHost, DefinitionBase model, SPFolder folder, WelcomePageDefinition welcomePgaeModel)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = welcomePgaeModel,
                ModelHost = modelHost
            });

            TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Changing welcome page to: [{0}]", welcomePgaeModel.Url);
            
            // https://github.com/SubPointSolutions/spmeta2/issues/431
            folder.WelcomePage = UrlUtility.RemoveStartingSlash(welcomePgaeModel.Url);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = welcomePgaeModel,
                ModelHost = modelHost
            });

            folder.Update();
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:31,代码来源:WelcomePageModelHandler.cs

示例5: CopyFolderCommand

 public CopyFolderCommand(SPFolder sourceFolder, string newUrl, string contentTypeId, SPWeb web)
     : base(web)
 {
     _NewUrl = newUrl;
     _SourceFolder = sourceFolder;
     _ContentTypeId = contentTypeId;
 }
开发者ID:jjaramillo,项目名称:Jjaramillo.SP2013,代码行数:7,代码来源:CopyFolderCommand.cs

示例6: DeployModuleFile

        public static void DeployModuleFile(SPFolder folder,
            string fileUrl,
            string fileName,
            byte[] fileContent,
            bool overwrite,
            Action<SPFile> beforeProvision,
            Action<SPFile> afterProvision)
        {
            // doc libs
            SPList list = folder.DocumentLibrary;

            // fallback for the lists assuming deployment to Forms or other places
            if (list == null)
            {
                list = folder.ParentWeb.Lists[folder.ParentListId];
            }

            WithSafeFileOperation(list, folder, fileUrl, fileName, fileContent,
                overwrite,
                onBeforeFile =>
                {
                    if (beforeProvision != null)
                        beforeProvision(onBeforeFile);
                },
                onActionFile =>
                {
                    if (afterProvision != null)
                        afterProvision(onActionFile);
                });
        }
开发者ID:ReneHezser,项目名称:spmeta2,代码行数:30,代码来源:ModuleFileModelHandler.cs

示例7: CheckFoldersForUnghostedFiles

        /// <summary>
        /// Checks the folders for unghosted files.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="unghostedFiles">The unghosted files.</param>
        internal static void CheckFoldersForUnghostedFiles(SPFolder folder, ref List<object> unghostedFiles, bool asString)
        {
            foreach (SPFolder sub in folder.SubFolders)
            {
                CheckFoldersForUnghostedFiles(sub, ref unghostedFiles, asString);
            }

            foreach (SPFile file in folder.Files)
            {
                if (file.CustomizedPageStatus == SPCustomizedPageStatus.Customized)
                {
                    if (asString)
                    {
                        string url = file.Web.Site.MakeFullUrl(file.ServerRelativeUrl);
                        if (!unghostedFiles.Contains(url))
                            unghostedFiles.Add(url);
                    }
                    else
                    {
                        if (!unghostedFiles.Contains(file))
                            unghostedFiles.Add(file);
                    }
                }
            }
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:30,代码来源:EnumUnGhostedFiles.cs

示例8: ProcessAllSubFolders

        private static bool ProcessAllSubFolders(SPFolder Folder, bool recursive, Func<SPFolder, bool> methodToCall)
        {
            IList<SPFolder> subFolders = Folder.SubFolders.Cast<SPFolder>().ToList<SPFolder>();

            foreach (SPFolder subFolder in subFolders)
            {
                //Loop through all sub webs recursively
                bool bContinue;

                bContinue = methodToCall.Invoke(subFolder);

                if (!bContinue)
                    return false;

                if (recursive && subFolder.Exists)
                {
                    bContinue = ProcessAllSubFolders(subFolder, recursive, methodToCall);

                    if (!bContinue)
                        return false;
                }
            }

            return true;
        }
开发者ID:powareverb,项目名称:spgenesis,代码行数:25,代码来源:SPGENFolderExtensions.cs

示例9: GetFile

        public static SPFile GetFile(SPFolder folder, string relativeFilePath)
        {
            var currentFolder = folder;
            var parts = relativeFilePath.Split('/');
            var pathFolders = parts.Take(parts.Length - 1);
            var fileName = parts.Last();

            try
            {
                foreach (var folderName in pathFolders)
                {
                    if (folderName == "..")
                        currentFolder = currentFolder.ParentFolder;
                    else
                        currentFolder = currentFolder.SubFolders.OfType<SPFolder>().FirstOrDefault(f => f.Name == folderName);

                    if (currentFolder == null || !currentFolder.Exists)
                        return null;
                }
            }
            catch (Exception exception)
            {
                var message = String.Format("Error on FileUtilities#GetFile for parameters \"{0}\", \"{1}\"\n{2}",
                    folder.ServerRelativeUrl, relativeFilePath, exception);
                SPMinLoggingService.LogError(message, TraceSeverity.Unexpected);
                return null;
            }

            return currentFolder.Files.OfType<SPFile>().FirstOrDefault(f => f.Name == fileName);
        }
开发者ID:spmin,项目名称:spmin,代码行数:30,代码来源:FileUtilities.cs

示例10: DeployContentTypeOrder

        private void DeployContentTypeOrder(object modelHost, SPList list, SPFolder folder, UniqueContentTypeOrderDefinition contentTypeOrderDefinition)
        {
            var oldContentTypeOrder = folder.ContentTypeOrder;
            var newContentTypeOrder = new List<SPContentType>();

            var listContentTypes = list.ContentTypes.OfType<SPContentType>().ToList();

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = contentTypeOrderDefinition,
                ModelHost = modelHost
            });

            // re-order
            foreach (var srcContentTypeDef in contentTypeOrderDefinition.ContentTypes)
            {
                SPContentType listContentType = null;

                if (!string.IsNullOrEmpty(srcContentTypeDef.ContentTypeName))
                    listContentType = listContentTypes.FirstOrDefault(c => c.Name == srcContentTypeDef.ContentTypeName);

                if (listContentType == null && !string.IsNullOrEmpty(srcContentTypeDef.ContentTypeId))
                    listContentType = listContentTypes.FirstOrDefault(c => c.Id.ToString().ToUpper().StartsWith(srcContentTypeDef.ContentTypeId.ToUpper()));

                if (listContentType != null && !newContentTypeOrder.Contains(listContentType))
                    newContentTypeOrder.Add(listContentType);
            }

            // filling up gapes
            foreach (var oldCt in oldContentTypeOrder)
            {
                if (newContentTypeOrder.Count(c =>
                    c.Name == oldCt.Name ||
                    c.Id.ToString().ToUpper().StartsWith(oldCt.Id.ToString().ToUpper())) == 0)
                    newContentTypeOrder.Add(oldCt);
            }

            if (newContentTypeOrder.Count() > 0)
                folder.UniqueContentTypeOrder = newContentTypeOrder;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = folder,
                ObjectType = typeof(SPFolder),
                ObjectDefinition = contentTypeOrderDefinition,
                ModelHost = modelHost
            });

            folder.Update();
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:58,代码来源:UniqueContentTypeOrderModelHandler.cs

示例11: MoveFolderCommand

 public MoveFolderCommand(SPFolder folder, string newUrl, string contentTypeId, SPWeb web)
     : base(web)
 {
     _NewUrl = newUrl;
     _Folder = folder;
     _Item = _Folder.Item;
     _OldUrl = string.Format("{0}/{1}", _SPWeb.Url, _Folder.Url);
     _ContentTypeId = contentTypeId;
 }
开发者ID:jjaramillo,项目名称:Jjaramillo.SP2013,代码行数:9,代码来源:MoveFolderCommand.cs

示例12: CopyItem

        public SPListItem CopyItem(SPListItem sourceItem, SPFolder destinationFolder)
        {
            SPListItem copiedItem = null;
            try
            {
                var destinationList = destinationFolder.ParentWeb.Lists[destinationFolder.ParentListId];

                if (destinationFolder.Item == null)
                {
                    copiedItem = destinationList.Items.Add();
                }
                else
                {
                    copiedItem = destinationFolder.Item.ListItems.Add(
                            destinationFolder.ServerRelativeUrl,
                            sourceItem.FileSystemObjectType);
                }

                foreach (string fileName in sourceItem.Attachments)
                {
                    SPFile file = sourceItem.ParentList.ParentWeb.GetFile(sourceItem.Attachments.UrlPrefix + fileName);
                    byte[] data = file.OpenBinary();
                    copiedItem.Attachments.Add(fileName, data);
                }

                for (int i = sourceItem.Versions.Count - 1; i >= 0; i--)
                {
                    foreach (SPField destinationField in destinationList.Fields)
                    {
                        SPListItemVersion version = sourceItem.Versions[i];

                        if (!version.Fields.ContainsField(destinationField.InternalName))
                            continue;

                        if ((!destinationField.ReadOnlyField) && (destinationField.Type != SPFieldType.Attachments) && !destinationField.Hidden
                            || destinationField.Id == SPBuiltInFieldId.Author || destinationField.Id == SPBuiltInFieldId.Created
                            || destinationField.Id == SPBuiltInFieldId.Editor || destinationField.Id == SPBuiltInFieldId.Modified)
                        {
                            if (destinationField.Type == SPFieldType.DateTime)
                            {
                                var dtObj = version[destinationField.InternalName];
                                copiedItem[destinationField.InternalName] = dtObj != null ?
                                    (object)destinationList.ParentWeb.RegionalSettings.TimeZone.UTCToLocalTime((DateTime)dtObj) : null;
                            }
                            else copiedItem[destinationField.Id] = version[destinationField.InternalName];
                        }
                    }
                    copiedItem.Update();
                }
                copiedItem[SPBuiltInFieldId.ContentTypeId] = sourceItem[SPBuiltInFieldId.ContentTypeId];
                copiedItem.SystemUpdate(false);
            }
            catch (Exception e)
            {}
            return copiedItem;
        }
开发者ID:Netbah,项目名称:SharePoint,代码行数:56,代码来源:CopyItems.cs

示例13: DeployPublishingPage

        private void DeployPublishingPage(object modelHost, SPList list, SPFolder folder, PublishingPageLayoutDefinition definition)
        {
            var web = list.ParentWeb;
            var targetPage = GetCurrentObject(folder, definition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = targetPage == null ? null : targetPage.File,
                ObjectType = typeof(SPFile),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            if (targetPage == null)
                targetPage = CreateObject(modelHost, folder, definition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = targetPage.File,
                ObjectType = typeof(SPFile),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            ModuleFileModelHandler.WithSafeFileOperation(list, folder,
                targetPage.Url,
                GetSafePageFileName(definition),
                Encoding.UTF8.GetBytes(definition.Content),
                definition.NeedOverride,
                null,
                afterFile =>
                {


                    var pageItem = afterFile.Properties;

                    pageItem["vti_title"] = definition.Title;
                    pageItem["MasterPageDescription"] = definition.Description;
                    pageItem[BuiltInInternalFieldNames.ContentTypeId] = BuiltInPublishingContentTypeId.PageLayout;

                    if (!string.IsNullOrEmpty(definition.AssociatedContentTypeId))
                    {
                        var siteContentType = web.AvailableContentTypes[new SPContentTypeId(definition.AssociatedContentTypeId)];

                        pageItem["PublishingAssociatedContentType"] = String.Format(";#{0};#{1};#",
                            siteContentType.Name,
                            siteContentType.Id.ToString());
                    }
                });
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:56,代码来源:PublishingPageLayoutModelHandler.cs

示例14: DeployInternall

        private void DeployInternall(SPList list, SPFolder folder, ListItemDefinition listItemModel)
        {
            if (IsDocumentLibray(list))
            {
                TraceService.Error((int)LogEventId.ModelProvisionCoreCall, "Please use ModuleFileDefinition to deploy files to the document libraries. Throwing SPMeta2NotImplementedException");

                throw new SPMeta2NotImplementedException("Please use ModuleFileDefinition to deploy files to the document libraries");
            }

            EnsureListItem(list, folder, listItemModel);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:11,代码来源:ListItemModelHandler.cs

示例15: WithSafeFileOperation

        public static void WithSafeFileOperation(
            SPList list,
            SPFolder folder,
            string fileUrl,
            string fileName,
            byte[] fileContent,
            bool overide,
            Action<SPFile> onBeforeAction,
            Action<SPFile> onAction)
        {
            var file = list.ParentWeb.GetFile(fileUrl);

            if (onBeforeAction != null)
                onBeforeAction(file);

            // are we inside ocument libary, so that check in stuff is needed?
            var isDocumentLibrary = list != null && list.BaseType == SPBaseType.DocumentLibrary;

            if (isDocumentLibrary)
            {
                if (list != null && (file.Exists && file.CheckOutType != SPFile.SPCheckOutType.None))
                    file.UndoCheckOut();

                if (list != null && (list.EnableMinorVersions && file.Exists && file.Level == SPFileLevel.Published))
                    file.UnPublish("Provision");

                if (list != null && (file.Exists && file.CheckOutType == SPFile.SPCheckOutType.None))
                    file.CheckOut();
            }

            SPFile newFile;

            if (overide)
                newFile = folder.Files.Add(fileName, fileContent, file.Exists);
            else
                newFile = file;

            if (onAction != null)
                onAction(newFile);

            newFile.Update();

            if (isDocumentLibrary)
            {
                if (list != null && (file.Exists && file.CheckOutType != SPFile.SPCheckOutType.None))
                    newFile.CheckIn("Provision");

                if (list != null && (list.EnableMinorVersions))
                    newFile.Publish("Provision");

                if (list != null && list.EnableModeration)
                    newFile.Approve("Provision");
            }
        }
开发者ID:ReneHezser,项目名称:spmeta2,代码行数:54,代码来源:ModuleFileModelHandler.cs


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