Zip 压缩问题件,获取真实扩展名
var _ZIP = new System.IO.Compression.ZipArchive(Request.Files[].InputStream); foreach (var element in _ZIP.Entries)
{
using (System.IO.StreamReader _ddd = new System.IO.StreamReader(element.Open()))
{
string _Text = _ddd.ReadToEnd(); } using (System.IO.BinaryReader _ddd = new System.IO.BinaryReader(element.Open()))
{
string bx = " ";
byte buffer;
buffer = r.ReadByte();
bx = buffer.ToString();
buffer = r.ReadByte();
bx += buffer.ToString(); //bx == 255216 jpg 파일
}
}
static void Main(string[] args)
{ string str = string.Empty;
str= Console.ReadLine();
Console.WriteLine("length:" + str.Length);
str=ToZip(str);
Console.WriteLine("ToZip:" + str);
Console.WriteLine("length:" + str.Length);
str= ToUnzip(str);
Console.WriteLine("ToUnzip:" + str);
Console.WriteLine("length:" + str.Length);
Console.Read();
} static string ToZip(string _str) { string result = string.Empty;
byte[] bString = Encoding.UTF8.GetBytes(_str);
using (var msi = new System.IO.MemoryStream(bString))
using (var mso = new System.IO.MemoryStream())
{
using (var gs = new System.IO.Compression.GZipStream(mso, System.IO.Compression.CompressionMode.Compress))
{
byte[] bTemp = new byte[];
int count;
while ((count = msi.Read(bTemp, , bTemp.Length)) != )
{
gs.Write(bTemp, , count);
}
}
result= System.Convert.ToBase64String(mso.ToArray());
}
return result;
}
static string ToUnzip(string _str)
{
string result = string.Empty;
byte[] bString = System.Convert.FromBase64String(_str);
using (var msi = new System.IO.MemoryStream(bString))
using (var mso = new System.IO.MemoryStream())
{
using (var gs = new System.IO.Compression.GZipStream(msi, System.IO.Compression.CompressionMode.Decompress))
{
byte[] bTemp = new byte[];
int count;
while ((count = gs.Read(bTemp, , bTemp.Length)) != )
{
mso.Write(bTemp, , count);
}
}
result= Encoding.UTF8.GetString(mso.ToArray());
} return result;
}
Zip 压缩问题件,获取真实扩展名的更多相关文章
- PHP获取文件扩展名的多种方法
PHP获取文件扩展名的N种方法. 第1种方法: function get_extension($file) { substr(strrchr($file, '.'), 1): } 第2种方法: fun ...
- C#根据byte前两位获取图片扩展名
C#根据byte前两位获取图片扩展名 /// <summary> /// 根据byte前两位获取图片扩展名 /// </summary> /// <param name= ...
- python获取文件扩展名的方法(转)
主要介绍了python获取文件扩展名的方法,涉及Python针对文件路径的相关操作技巧.具体实现方法如下: 1 2 3 4 import os.path def file_extension(path ...
- python获取文件扩展名的方法
主要介绍了python获取文件扩展名的方法,涉及Python针对文件路径的相关操作技巧 import os.path def file_extension(path): ] print file_ex ...
- PHP中获取文件扩展名的N种方法
PHP中获取文件扩展名的N种方法 从网上收罗的,基本上就以下这几种方式: 第1种方法:function get_extension($file){substr(strrchr($file, '.'), ...
- PHP获取文件扩展名五种以上的方法和注释
在PHP面试中或者考试中会有很大几率碰到写出五种获取文件扩展名的方法,下面是我自己总结的一些方法 $file = ‘需要进行获取扩展名的文件.php’; //第一种,根据.拆分,获取最后一个元素的值f ...
- PHP中获取文件扩展名
function get_extension($file) { return substr(strrchr($file, '.'), 1) ; } function get_extension($fi ...
- PHP获取文件扩展名的五种方式
这是我应聘实习时遇到的一道笔试题: 使用五种以上方式获取一个文件的扩展名. 要求:dir/upload.image.jpg,找出 .jpg 或者 jpg , 必须使用PHP自带的处理函数进行处理,方法 ...
- PHP 获取文件扩展名的五种方式
第一种 substr(strrchr("http://www.xxx.com/public/abc.jpg", '.'), 1); string strrchr('string', ...
随机推荐
- 使用Facebook的create-react-app脚手架快速构建React开发环境(ant.design,redux......)
编程领域中的“脚手架(Scaffolding)”指的是能够快速搭建项目“骨架”的一类工具.例如大多数的React项目都有src,public,webpack配置文件等等,而src目录中又包含compo ...
- 一个简单好用的zabbix告警信息发送工具
之前使用邮件和短信发送zabbix告警信息,但告警信息无法实时查看或者无法发送,故障无法及时通知运维人员. 后来使用第三方微信接口发送信息,愉快地用了一年多,突然收费了. zabbix告警一直是我的痛 ...
- 使用神经网络识别手写数字Using neural nets to recognize handwritten digits
The human visual system is one of the wonders of the world. Consider the following sequence of handw ...
- 通过JSONP实现完美跨域
通过JSONP实现完美跨域 三水清 2010-06-11 20:17:47 以前我经常在博客说JSONP,例如我的WordPress天气插件就是通过JSONP来调用的天气数据,今天就说说通过JSONP ...
- app store 注册账号生成证书上传app完整的教程
app store为开发者提供四种类型的申请: 个人ios开发者计划$99/年 公司ios开发者计划$99/年 企业ios开发者计划$299/年 高校ios开发者计划免费 在这里主要介绍一下公司ios ...
- 转: android sdk for mac
转:http://www.cnblogs.com/yjmyzz/p/4219829.html 众所周知的原因,google的很多网站在国内无法访问,苦逼了一堆天朝程序员,下是在mac本上折腾andro ...
- Zend Guard Run-time support missing 问题的解决
Zend Guard是目前市面上最成熟的PHP源码加密产品了. 刚好需要对自己的产品进行加密,折腾了一晚上,终于搞定,将碰到的问题及解决方法记录下来,方便日后需要,也可以帮助其他人. 我使用的是Wam ...
- TestNG系列之四: TestNg依赖 dependsOnMethods
有时候,你可能需要在一个特定的顺序调用方法 执行原则: 1.被依赖的先执行: 2. 再执行没配置依赖的, 3.再执行需要依赖的: 4.若无依赖关系,依次执行) 一个方法有多个依赖时用空格隔开 有两种依 ...
- 使用JTextArea示例
相对于JLabel显示提示文字,JTextArea有一个先天优势:文字可以拷贝出来.经过下面设置它也能在外观上和JLabel一致. 代码如下: JTextArea txtArea=new JTextA ...
- CSS学习(九)-CSS背景
一.理论: 1.background-break a.bounding-box 背景图像在整个内联元素中进行平铺 b.each-box 背景图像在行内中进行平铺 c.continuous 下一行的背 ...