/// <summary> /// 文件验证 /// </summary> /// <param name="Files">文件名</param> /// <param name="ext">扩展名</param> /// <returns></returns> private static bool IsStr(string Files, string ext) { try { string namex = ext; string ex = (IOFiles.GetExtension(Files)).ToLower(); foreach (string extname in namex.ToString().Split('|')) { if (ex == extname) { return(true); } } return(false); } catch { return(false); } }
//根据原图片,缩微图大小等比例缩放 文件 private void TimedProgress() { ImageCodecInfo icf = ImageHelper.GetImageCodecInfo(ImageFormat.Jpeg); Image image, thumbnailImage; string thumbnailImageFilename; if (SafeCheck.IsJPGstr(file)) { string extension; extension = IOFiles.GetExtension(file); try { using (image = Image.FromFile(file)) { Size imageSize = GetImageSize(image); using (thumbnailImage = ImageHelper.GetThumbnailImage(image, imageSize.Width, imageSize.Height)) { if (IsthumbnailImage) { thumbnailImageFilename = IOFiles.Combine(thumbnailPath, IOFiles.GetFileNameWithoutExtension(file) + extension); } else { thumbnailImageFilename = this._newfile; } ImageHelper.SaveImage(thumbnailImage, thumbnailImageFilename, icf); } } } catch (Exception ex) { string em = ex.Message; } } }