.net软件授权,生成授权码,授权文件


.net软件授权,生成授权码,授权文件制作,其中有软件授权代码
资源截图
代码片段和文件信息
using System;
using System.IO;
using System.IO.Compression;
using System.Windows.Forms;
class clsZip
{
    public void CompressFile(string sourceFile string destinationFile)
    {
        // make sure the source file is there
        if (File.Exists(sourceFile) == false)
            throw new FileNotFoundException();

        // Create the streams and byte arrays needed
        byte[] buffer = null;
        FileStream sourceStream = null;
        FileStream destinationStream = null;
        GZipStream compressedStream = null;

        try
        {
            // Read the bytes from the source file into a byte array
            sourceStream = new FileStream(sourceFile FileMode.Open FileAccess.Read FileShare.Read);

            // Read the source stream values into the buffer
            buffer = new byte[sourceStream.Length];
            int checkCounter = sourceStream.Read(buffer 0 buffer.Length);

            if (checkCounter != buffer.Length)
            {
                throw new ApplicationException();
            }

            // Open the FileStream to write to
            destinationStream = new FileStream(destinationFile FileMode.OpenOrCreate FileAccess.Write);

            // Create a compression stream pointing to the destiantion stream
            compressedStream = new GZipStream(destinationStream CompressionMode.Compress true);

            // Now write the compressed data to the destination file
            compressedStream.Write(buffer 0 buffer.Length);
        }
        catch (ApplicationException ex)
        {
            MessageBox.Show(ex.Message “压缩文件时发生错误:“ MessageBoxButtons.OK MessageBoxIcon.Error);
        }
        finally
        {
            // Make sure we allways close all streams
            if (sourceStream != null)
                sourceStream.Close();

            if (compressedStream != null)
                compressedStream.Close();

            if (destinationStream != null)
                destinationStream.Close();
        }
    }

    public void DecompressFile(string sourceFile string destinationFile)
    {
        // make sure the source file is there
        if (File.Exists(sourceFile) == false)
            throw new FileNotFoundException();

        // Create the streams and byte arrays needed
        FileStream sourceStream = null;
        FileStream destinationStream = null;
        GZipStream decompressedStream = null;
        byte[] quartetBuffer = null;

        try
        {
            // Read in the compressed source stream
            sourceStream = new FileStream(sourceFile FileMode.Open);

            // Create a compression stream pointing to the destiantion stream
            decompressedStream = new GZipStream(sourceStream CompressionMode.Decompress true);

            // Read the footer to determine the length of the destiantion file
            quartetBuffer = new byte[4];
            int

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件          62  2018-03-27 17:42  博客地址.txt
     文件      178176  2015-12-11 21:19  说明.doc
     目录           0  2018-03-27 17:40  软件授权
     目录           0  2018-03-27 17:40  软件授权许可安装
     文件        2385  2015-12-11 20:54  软件授权许可安装Form1.Designer.cs
     文件         987  2015-12-11 20:54  软件授权许可安装Form1.cs
     文件        6025  2015-12-11 20:54  软件授权许可安装Form1.resx
     文件         473  2015-12-11 20:30  软件授权许可安装Program.cs
     目录           0  2015-12-11 20:30  软件授权许可安装Properties
     文件        1366  2015-12-11 20:30  软件授权许可安装PropertiesAssemblyInfo.cs
     文件        2876  2015-12-11 20:30  软件授权许可安装PropertiesResources.Designer.cs
     文件        5612  2015-12-11 20:30  软件授权许可安装PropertiesResources.resx
     文件        1099  2015-12-11 20:30  软件授权许可安装PropertiesSettings.Designer.cs
     文件         249  2015-12-11 20:30  软件授权许可安装PropertiesSettings.settings
     目录           0  2015-12-11 20:30  软件授权许可安装in
     目录           0  2015-12-11 21:08  软件授权许可安装inDebug
     文件       10240  2015-12-11 21:08  软件授权许可安装inDebug许可安装.exe
     文件       24064  2015-12-11 21:08  软件授权许可安装inDebug许可安装.pdb
     文件       21656  2015-12-11 21:03  软件授权许可安装inDebug许可安装.vshost.exe
     文件         490  2013-03-18 17:00  软件授权许可安装inDebug许可安装.vshost.exe.manifest
     文件        4597  2015-12-11 20:53  软件授权许可安装clsZip.cs
     目录           0  2015-12-11 20:30  软件授权许可安装obj
     目录           0  2015-12-11 21:08  软件授权许可安装objDebug
     文件        6106  2015-12-11 20:53  软件授权许可安装objDebugDesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2018-03-27 17:43  软件授权许可安装objDebugTempPE
     文件         180  2015-12-11 21:08  软件授权许可安装objDebug许可安装.Form1.resources
     文件         180  2015-12-11 21:08  软件授权许可安装objDebug许可安装.Properties.Resources.resources
     文件         709  2015-12-11 21:08  软件授权许可安装objDebug许可安装.csproj.FileListAbsolute.txt
     文件         847  2015-12-11 21:08  软件授权许可安装objDebug许可安装.csproj.GenerateResource.Cache
     文件       10240  2015-12-11 21:08  软件授权许可安装objDebug许可安装.exe
     文件       24064  2015-12-11 21:08  软件授权许可安装objDebug许可安装.pdb
............此处省略104个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)