日期:2014-05-18 浏览次数:20574 次
//255216:jpg格式 7173:gif格式 6677:bmp格式 13780:png格式 public static string IsImage(string path) { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); string fileclass = ""; byte bufer; try { bufer = br.ReadByte(); fileclass = bufer.ToString(); bufer = br.ReadByte(); fileclass += bufer.ToString(); } catch { } return fileclass; }
------解决方案--------------------
http://topic.csdn.net/u/20090306/14/0241a60e-f0f3-444f-8377-b8ac4306e833.html