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


C# SPFolder.FileExists方法代码示例

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


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

示例1: BuildDestinationFilename

 private string BuildDestinationFilename(string filename, SPFolder destFolder)
 {
     if (destFolder.FileExists(filename))
     {
         filename = string.Format("{0}_(ItemId_{1}){2}",
             Path.GetFileNameWithoutExtension(filename),
             _sourceListItem.ID,
             Path.GetExtension(filename));
     }
     return filename;
 }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:11,代码来源:ExtractAttachmentsActivity.cs

示例2: CopyAttachmentsAndMetaDataToDestinationLibrary

        private void CopyAttachmentsAndMetaDataToDestinationLibrary(SPFolder destinationFolder, SPContentType destinationContentType)
        {
            InfoPathHelper ipHelper;
            ipHelper = new InfoPathHelper(this.__ActivationProperties);

            try
            {
                ipHelper.LoadForm();
            }
            catch
            {
                this.__ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.WorkflowError, Constants.Workflow.ERROR_LOAD_INFOPATH_FORM_DATA, string.Empty);
            }

            try
            {
                //attachment path not exist or is null, log and exit function
                if (ipHelper.NodeIsNullOrNotExistAt(this.AttachmentFieldPath))
                {
                    this.__ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.WorkflowComment, string.Format(Constants.Workflow.ERROR_INFOPATH_FORM_VALUE_IS_NULL_OR_NOT_EXIST, this.AttachmentFieldPath), string.Empty);
                    return;
                }

                //log message when description path is null or not exist
                if (ipHelper.NodeIsNullOrNotExistAt(this.DescriptionFieldPath))
                {
                    this.__ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.WorkflowComment, string.Format(Constants.Workflow.ERROR_LOAD_DESCRIPTION_INFOPATH_FORM_VALUE, this.DescriptionFieldPath), string.Empty);
                }

                //log message when destination description field name not exist
                var descriptionField = destinationFolder.DocumentLibrary.Fields.Cast<SPField>().ToList().FirstOrDefault(p => string.Compare(p.Title, this.DescriptionFieldName.Trim(), true) == 0);
                if (descriptionField == null)
                {
                    this.__ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.WorkflowComment, string.Format(Constants.Workflow.ERROR_FIELD_NAME_NOT_EXIST_ON_LIBRARY, this.DescriptionFieldName), string.Empty);
                }

                List<InfoPathAttachment> attachments = ipHelper.GetFilesFromPath(this.AttachmentFieldPath, this.DescriptionFieldPath);
                if (attachments.Count == 0)
                {
                    this.__ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.WorkflowComment, string.Format(Constants.Workflow.ERROR_NO_ATTACHMENT, this.AttachmentFieldPath), string.Empty);
                    return;
                }

                foreach (InfoPathAttachment attachment in attachments)
                {
                    string destinationFileURL = destinationFolder.Url + "/" + attachment.Filename.ConvertToValidSharePointFileName();
                    //file exist
                    if (!this.overrideDetinationFile && destinationFolder.FileExists(attachment.Filename))
                    {
                        string errorMessage = string.Format(Constants.Workflow.ERROR_FILE_EXIST, attachment.Filename, this.DestinationFolderUrl);
                        this.__ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.WorkflowComment, errorMessage, string.Empty);
                        continue;
                    }

                    if (UsingAccount == "System")
                    {
                        UploadWithSystemAccount(destinationFolder, destinationContentType, descriptionField, attachment, destinationFileURL);
                    }
                    else
                    {
                        UploadWithOriginatorUser(destinationFolder, destinationContentType, descriptionField, attachment, destinationFileURL);
                    }

                    this.__ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.WorkflowComment, string.Format(Constants.Workflow.UPLOAD_FILE_SUCESSFULLY, attachment.Filename, this.DestinationFolderUrl), string.Empty);
                }
            }
            catch
            {
                this.__ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.WorkflowError, Constants.Workflow.ERROR_UPLOADING_FILE, string.Empty);
            }
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:71,代码来源:ExtractIPAttachments.cs


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