public static bool CannotOpenContentInFileType(IFile file, string[] fileTypes) { FileAttributeAnalysis fileAttributeAnalyzer = new FileAttributeAnalysis(); if (fileAttributeAnalyzer.IsOfFileType(file, fileTypes)) { return (!file.CanOpenContent || file.WasProtectedOrEncrypted); } return false; }
/// <summary> /// Looks for a restriction custom property in a specified file type /// </summary> /// <param name="file">The file to evaluate</param> /// <param name="fileTypes">An array of file types</param> /// <param name="type">The data type of the custom property</param> /// <param name="name">The name of the custom property</param> /// <param name="value">The value of the custom property</param> /// <returns>A boolean representing whether our file is in the list file types AND our file contains an exact match for custom property type, name and value</returns> public bool RestrictionPropertyMatchInFileType(IFile file, string[] fileTypes, string type, string name, string value) { FileAttributeAnalysis fileAttributes = new FileAttributeAnalysis(); if (fileAttributes.IsOfFileType(file, fileTypes)) { return PropertyMatch(file, type, name, value); } return false; }
public static DictionaryEntry[] RegExLookupInFileType(IFile file, string[] fileTypes, string regex, string[] contexts) { IFile convertedFile = null; try { convertedFile = TryConvertToUsefulFileType(file, ref fileTypes, contexts ); if (file == null) { return new DictionaryEntry[0]; } FileAttributeAnalysis fileAttributeAnalyzer = new FileAttributeAnalysis(); if (fileAttributeAnalyzer.IsOfFileType(convertedFile, fileTypes)) { return RegExLookup(file, regex, contexts); } return new DictionaryEntry[0]; } finally { if (Workshare.Interop.Options.OptionApi.GetBool("UseDiskBasedFiles") && convertedFile != null && !IFile.ReferenceEquals(convertedFile, file) && !string.IsNullOrEmpty(convertedFile.FileName)) { try { System.IO.File.Delete(convertedFile.FileName); } catch { } } } }