
正文
vb.net压缩 vb文件压缩后打不开
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net 如何压缩、解压缩文件
1、你先搞懂 winrar.exe 的解压参数格式vb.net压缩,然后把winrar.exe和相关文件加入到资源文件中vb.net压缩,然后调用 资源文件中的winrar.exe
2、弄明白rar/zip文件解压/压缩方法和格式vb.net压缩,自己写程序 (可能会比较麻烦)
相关问答
Q1: VB.net 如何将TXT文件转换压缩成.gz文件
手机敲很累的!一定要给分啊!格式是:tar 选项 文件.选项有 -c:产生打包文件 -v:显示详细信息 -f:指定压缩后的文件名 -z:打包同时压缩!举个例子吧!将目录my打包并压缩成my.tar.gz就这样tar -zcvf my.tar.gz my
Q2: 用vb.net对sql多数据库压缩备份为一个文件
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using _5dRss.Const;
using _5dRss.lib.Data.Tool;
public partial class admin_admin_dbmanage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//生成备份文件列表
ListBackupFiles();
if (!Page.IsPostBack)
{
Showmsg.Visible = false;
//数据库路径
lilDBPath.Text = HttpContext.Current.Request.PhysicalApplicationPath + "App_Data\\" + ConfigurationSettings.AppSettings["DBFile"];
//新建一个 FileInfo 对象,并获得数据库文件的大小,然后转换单位为KB
FileInfo myFileInfo = new FileInfo(lilDBPath.Text);
lilDBSize.Text = Convert.ToString(myFileInfo.Length/1024) + " KB";
//如果两个参数都不为空,则继续执行
if (Request.QueryString["cmd"] != null Request.QueryString["source"] != null)
{
//备份数据库原文件名
string sourceFileName = Request.QueryString["source"];
//如果 cmd 参数为 DelFile
if (Request.QueryString["cmd"].Equals("DelFile"))
{
//删除备份数据库文件
File.Delete(HttpContext.Current.Request.PhysicalApplicationPath + "Backup\\" + sourceFileName);
//刷新备份文件列表
ListBackupFiles();
Showmsg.Visible = true;
Showmsg.Text = "div align='center' style='margin-bottom:8px;'img src='images/aL.gif' style='margin-bottom:-6px;'/span class='alertTxt'删除备份数据库成功!/spanimg src='images/aR.gif' style='margin-bottom:-6px;'//div";
}
//如果 cmd 参数为 Restore
if (Request.QueryString["cmd"].Equals("Restore"))
{
//用备份文件覆盖原文件
File.Copy(HttpContext.Current.Request.PhysicalApplicationPath + "Backup\\" + sourceFileName, HttpContext.Current.Request.PhysicalApplicationPath + "App_Data\\" + ConfigurationSettings.AppSettings["DBFile"], true);
//刷新备份文件列表
ListBackupFiles();
Showmsg.Visible = true;
Showmsg.Text = "div align='center' style='margin-bottom:8px;'img src='images/aL.gif' style='margin-bottom:-6px;'/span class='alertTxt'还原备份数据库成功!/spanimg src='images/aR.gif' style='margin-bottom:-6px;'//div";
}
}
}
}
protected void lnkbtnCompactDB_Click(object sender, EventArgs e)
{
//压缩修复数据库
AccessDBtool.CompactAccessDB(SysConfig.ConnectionString, HttpContext.Current.Request.PhysicalApplicationPath + "App_Data\\" + ConfigurationSettings.AppSettings["DBFile"]);
Showmsg.Visible = true;
Showmsg.Text = "div align='center' style='margin-bottom:8px;'img src='images/aL.gif' style='margin-bottom:-6px;'/span class='alertTxt'压缩修复数据库成功!/spanimg src='images/aR.gif' style='margin-bottom:-6px;'//div";
}
protected void lnkbtnBackupDB_Click(object sender, EventArgs e)
{
string sourceFileName = HttpContext.Current.Request.PhysicalApplicationPath + "App_Data\\" + ConfigurationSettings.AppSettings["DBFile"];
string destFileName = HttpContext.Current.Request.PhysicalApplicationPath + "Backup\\" + "Backup_";
destFileName += DateTime.Now.ToString("yyyyMMddHHmmss");
destFileName += ".mbk";
//将数据库文件Copy到Backup目录,如果有重名文件就覆盖原文件
File.Copy(sourceFileName, destFileName, true);
//生成备份文件列表
ListBackupFiles();
Showmsg.Visible = true;
Showmsg.Text = "div align='center' style='margin-bottom:8px;'img src='images/aL.gif' style='margin-bottom:-6px;'/span class='alertTxt'备份数据库成功!/spanimg src='images/aR.gif' style='margin-bottom:-6px;'//div";
}
/// summary
/// 生成备份文件列表
/// /summary
/// returns文件列表,文件详细信息及操作选项的HTML代码/returns
public void ListBackupFiles()
{
//如果目录不存在则创建次目录
if (!Directory.Exists(HttpContext.Current.Request.PhysicalApplicationPath + "Backup\\"))
Directory.CreateDirectory(HttpContext.Current.Request.PhysicalApplicationPath + "Backup\\");
DirectoryInfo mydir = new DirectoryInfo(HttpContext.Current.Request.PhysicalApplicationPath + "Backup\\");
StringBuilder sb = new StringBuilder();
foreach (FileInfo f in mydir.GetFiles())
{
sb.Append("a href='backup/" + f.Name + "' target='_blank'img border='0' src='images/mdb.gif' style='margin:4px 3px -3px 0px'/" + f.Name + "/a a href='?cmd=DelFilesource=" + f.Name + "' title='删除备份文件'删除/a | a href='?cmd=Restoresource=" + f.Name + "' title='删除备份文件'还原数据库/a | " + f.Length/1024 + " KB | " + f.CreationTime + "br /");
}
lilBackupFileList.Text = sb.ToString();
}
}
把下面这句换成你的数据库地址:
//数据库路径
// lilDBPath.Text = HttpContext.Current.Request.PhysicalApplicationPath + "App_Data\\" + ConfigurationSettings.AppSettings["DBFile"];
Q3: asp.net如何实现 图片压缩(vb.net)
'''''''''''''''tosmallimg.aspx''
%@ Page Language="VB" AutoEventWireup="false" CodeFile="tosmallpic.aspx.vb" Inherits="tosmallpic" %
%@ OutputCache Duration="86400" VaryByParam="*" %
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head runat="server"
title无标题页/title
/head
body
form id="form1" runat="server"
div
/div
/form
/body
/html
'''''''''''''''tosmallimg.aspx.vb''
Imports System.Drawing, System.Drawing.Imaging, System.Drawing.Drawing2D
Partial Class tosmallpic
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim width As Int16 = CInt(My.Request.QueryString("width"))
Dim height As Int16 = CInt(My.Request.QueryString("height"))
Dim url As String = My.Request.QueryString("url")
If Not System.IO.File.Exists(Server.MapPath(url)) Then
Response.Redirect("img/default.jpg")
Response.End()
End If
Dim img As Image = Image.FromFile(Server.MapPath(url))
If width = 0 And height 0 Then
width = height * img.Width / img.Height
ElseIf height = 0 Then
height = width * img.Height / img.Width
End If
If width img.Width Then Response.Redirect(url)
Dim bmp As New Bitmap(width, height)
Dim gr As Graphics = Graphics.FromImage(bmp)
gr.Clear(Color.Transparent)
'gr.SmoothingMode = SmoothingMode.AntiAlias
Dim rct As New Rectangle(0, 0, width, height)
gr.DrawImage(img, New Rectangle(0, 0, width, height), New Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel)
Response.Clear()
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, ImageFormat.Jpeg)
End Sub
End Class
介绍下vb.net压缩我vb.net压缩的blog
Q4: VB.net环境下 不接压直接读取GZ压缩文件内容?能实现吗?
直接读取 一个gz压缩文件:
我直接创建了一个内容:"asdfasdfasfd" 的 1.txt文件并用gzip 压缩。
读取:
$ zcat 1.txt.gz
asdfasdfasfd
如果内容过长可以接 less 查看:
$ zcat 1.txt.gz | less
Q5: vb.net进行文件压缩
如果机器安装有winRar软件vb.net压缩,就可以通过shell来借用vb.net压缩他的功能达到压缩文件的效果vb.net压缩;
参考代码如下:
Dim DeliveryF As String = Server.MapPath("..\Temp\DeliveryFactors.xls") '原始文件 (压缩前)
Dim TruckInfo As String = Server.MapPath("..\Temp\TruckInformation.xls")
Dim QDetail As String = Server.MapPath("..\Temp\QuotationDetail.xls")
'用shell命令调用winrar.exe创建压缩文件()
Dim winRarexe As String = "C:\Program Files\WinRAR\Rar" 'winzip 执行文件的位置
Dim wtarget As String = "C:\temp\QuotationVAComparsion.zip" '目地文件 (压缩后)
Dim command As String = winRarexe " a " wtarget " " DeliveryF " " TruckInfo " " QDetail
'这个命令你可以查看winrar的命令集
Dim retval As Double 'Shell 指令传回值
retval = Shell(command, AppWinStyle.MinimizedFocus)
关于vb.net压缩和vb文件压缩后打不开的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。








