110,545
社区成员
发帖
与我相关
我的任务
分享
FileStream fs = new FileStream(txb_File.Text, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
byte[] b = new byte[30];
MemoryStream ms = new MemoryStream();
r.Read(b, 0, b.Length);
// ...
r.Close();
fs.Close();
bool xx=false; //default sFileName is not Exe or Dll File
System.IO.FileStream fs=new System.IO.FileStream(sFileName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
System.IO.BinaryReader r=new System.IO.BinaryReader(fs);
string bx="";
byte buffer;
try
{
buffer=r.ReadByte();
bx=buffer.ToString();
buffer=r.ReadByte();
bx+=buffer.ToString();
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
r.Close();
fs.Close();
if (bx=="7790"||bx=="8297"||bx=="8075")//7790:exe,8297:rar,8075:pk
{
xx=true;
}
Console.WriteLine(bx);
return xx;
public static string GetContentTypeByExtName(string extName)
{
switch (extName.ToLower())
{
case ".001":
return "application/x-001";
case ".301":
return "application/x-301";
case ".323":
return "text/h323";
case ".906":
return "application/x-906";
case ".907":
return "drawing/907";
.........
....
return "application/x-wrk";
case ".ws":
return "application/x-ws";
case ".ws2":
return "application/x-ws";
case ".wsc":
return "text/scriptlet";
case ".wsdl":
return "text/xml";
case ".wvx":
return "video/x-ms-wvx";
case ".xdp":
return "application/vnd.adobe.xdp";
case ".xdr":
return "text/xml";
case ".xfd":
return "application/vnd.adobe.xfd";
case ".xfdf":
return "application/vnd.adobe.xfdf";
case ".xhtml":
return "text/html";
case ".xls":
return "application/x-xls";
case ".xlw":
return "application/x-xlw";
case ".xml":
return "text/xml";
case ".xpl":
return "audio/scpls";
case ".xq":
return "text/xml";
case ".xql":
return "text/xml";
case ".xquery":
return "text/xml";
case ".xsd":
return "text/xml";
case ".xsl":
return "text/xml";
case ".xslt":
return "text/xml";
case ".xwd":
return "application/x-xwd";
case ".x_b":
return "application/x-x_b";
case ".x_t":
return "application/x-x_t";
}
return "application/octet-stream";
}