private static SupportedFileType GetCorrectedSupportedFileType(int fileTypeIndex, string fileName, IList <SupportedFileType> fileTypes) { var fileType = fileTypes[fileTypeIndex]; // check if the selected type in the filter contains the extension of the path // if it doesn't, try to find the first best matching type var extension = Path.GetExtension(fileName); if (extension != null) { var info = SupportedFileManager.GetSupportedFileInfo(fileType); if (!info.Extensions.Contains(extension, StringComparer.InvariantCultureIgnoreCase)) { var actualInfo = SupportedFileManager.SupportedFileInfos .Where(x => fileTypes.Contains(x.EnumType)) .FirstOrDefault( x => x.Extensions.Contains(extension, StringComparer.InvariantCultureIgnoreCase)); if (actualInfo != null) { fileType = actualInfo.EnumType; } } } return(fileType); }
public bool Add(string path) { var fileInfo = SupportedFileManager.GetSupportedFileInfo(Path.GetExtension(path)); return(Add(path, fileInfo.EnumType)); }
public MemoryStream GetResourceMemoryStream() { var info = SupportedFileManager.GetSupportedFileInfo(typeof(TResource)); return(info.GetStream(Resource)); }