开发我自己的zip压缩软件 [英] Development of a zip compression software of my own

查看:136
本文介绍了开发我自己的zip压缩软件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好..我想开发一个实用程序,可以像C#.NET中的Power ISO,Win RAR等其他压缩应用程序一样工作。



假设我想使用Win RAR压缩文件或文件夹,它会创建一个.rar文件。我想要的是编写我自己的应用程序,它可以压缩文件/文件夹并使用我自己的扩展名保存它们,只有我的应用程序可以在其上执行I / O.我试图找到很多天的解决方案,但一切都是徒劳的。



如果有人能给我一个正确方向的推动,我真的很感激它。



问候

-Saim Shaukat

解决方案

试试这个会有所帮助你。



压缩和提取文件



GZipStream类



ZipFile Class



压缩c#


任何可以读取的文件都可以被任何应用程序读取。你不能阻止它 - 因为它也会阻止你的应用程序表单能够读取它并将你的硬盘驱动器变成只写内存。



你能做的就是加密模糊文件内容,以便只有您可以在阅读后理解内容。这并不难,但需要大量的背景阅读才能确保安全。



从这里开始: http://msdn.microsoft.com/en-us/library/as0w18af(v = vs.110)的.aspx [ ^ ]并按照链接。然后开始考虑你想要达到的目标以及最适合的目标。



为了压缩,你需要使用像zipsharp这样的包,或者自己编写: http://en.wikipedia.org/wiki/Data_compression [ ^ ]概述了您可能实现的各种方法。


< blockquote>只有建议,需要改进。



 使用系统; 
使用 System.IO;
使用 System.IO.Compression;

命名空间 ConsoleApplication
{
class Program
{
静态 void Main( string [] args)
{
string startPath = @ c:\ example = \\ start;
string zipPath = @ c:\\ \\example\result.zip;
string extractPath = @ c:\\ \\example\extract;
string myFile = @ c:\\ \\example\result.xxx;

ZipFile.CreateFromDirectory(startPath,zipPath);

/// 使用MyScrambleAlgo函数在xxx文件中压缩zip文件,可能使用数组字节
/// TODO

/// 更改名称:zipPath => myFile.xxx
/// TODO

/// 现在你有自定义的zip和scrambled文件,只有你可以打开它

/// 要读取文件,请按相反的顺序执行相同操作
/// 使用MyUnScrambleAlgo函数解压缩zip文件中的xxx文件,可能使用字节
的数组
/// TODO

/// 更改名称myfile.xxx => zipPath
/// TODO

ZipFile .ExtractToDirectory(zipPath,extractPath);
}



}
}





希望帮助

您好


Hello.. I want to develop a utility which can work as other compression applications like Power ISO, Win RAR in C#.NET.

Suppose i want to compress a file or folder using Win RAR it creates a.rar file. The thing i want is to write my own application which can compress file/folders and save them with the extension of my own and only my application can perform I/O on it. I am trying to find a solution from many days but all in vain.

If someone could just give me a nudge in the correct direction, I'd really appreciate it.

Regards
-Saim Shaukat

解决方案

try this it will help you.

Compress and Extract Files

GZipStream Class

ZipFile Class

compression in c#


Any file that can be read, can be read by any application. You cannot prevent that - because it would also prevent your application form being able to read it and that turns your hard drive into Write Only Memory.

What you can do is encrypt of obfuscate the file contents so that only your can understand the content once it is read. That's not difficult, but requires a good deal background reading in order to make it secure.

Start here: http://msdn.microsoft.com/en-us/library/as0w18af(v=vs.110).aspx[^] and follow the links. Then start thinking about exactly what you are trying to achieve and what best fits that.

In order to compress as well, you will need to use a package like zipsharp, or write your own: http://en.wikipedia.org/wiki/Data_compression[^] gives an overview of the various methods you might implement.


Only a suggestion , need improvements.

using System;                                                                              
using System.IO;
using System.IO.Compression;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string startPath = @"c:\example\start";
            string zipPath = @"c:\example\result.zip";
            string extractPath = @"c:\example\extract";
            string myFile = @"c:\example\result.xxx";

            ZipFile.CreateFromDirectory(startPath, zipPath);

            /// Scamble zip file in xxx file with an MyScrambleAlgo function, likely using an array of byte
            /// TODO

            /// Change name : zipPath =>  myFile.xxx
            /// TODO

            /// Now you have your custom zip and scrambled file , only you can open it
 
            /// To read your file do the same in reverse order
            /// Unscramble xxx file in zip file with an MyUnScrambleAlgo function, likely using an array of byte
            /// TODO

            /// Change name myfile.xxx => zipPath
            /// TODO

            ZipFile.ExtractToDirectory(zipPath, extractPath);
        }



    }
}



Hope help
Hi


这篇关于开发我自己的zip压缩软件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆