本文整理汇总了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;
}
示例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);
}
}