Parsi Coders
سورس کد فشرده سازی فایل ,قرار دادن پسوورد و اپلود فایل (asp.net) - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Web Development and Design (http://parsicoders.com/forumdisplay.php?fid=47)
+--- انجمن: ASP, ASP.NET (http://parsicoders.com/forumdisplay.php?fid=49)
+--- موضوع: سورس کد فشرده سازی فایل ,قرار دادن پسوورد و اپلود فایل (asp.net) (/showthread.php?tid=2211)



سورس کد فشرده سازی فایل ,قرار دادن پسوورد و اپلود فایل (asp.net) - Amin_Mansouri - 05-02-2012

با سورس زیر میتونید یک فایل رو اپلود کنید و تبدیل به زیپ کنید و حتی روش پسوورد بزارید !



عکسی از سورس:

[عکس: 43505-221821-5ZipWeb1.jpg]



قسمتی از سورس :

کد:
using Ionic.Zip;

using System.IO;



public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {



    }

    protected void btnZip_Click(object sender, EventArgs e)

    {        

        // SINGLE FILE UPLOAD AND ZIP EXAMPLE START //



        try

        {

            if (FileUpload1.HasFile)

            {        

                // Mention path where your zip file save

                var path = "E:\\" + FileUpload1.FileName + ".zip";



                // Zip File and save in your mentioned path

                using (var zip = new ZipFile())

                {

                    zip.AddEntry(FileUpload1.FileName, FileUpload1.FileContent);

                    zip.Save(path);

                }



                lblmsg.Text = "Single file zipped successfully here :   " + path + "



";

            }

            else

            {

                lblmsg.Text = "Select file to be archieve!";

            }

        }

        catch(Exception ex)

        {

            lblmsg.Text="Error During Zip operation " + ex.ToString();

        }



        // SINGLE FILE UPLOAD AND ZIP EXAMPLE END //

                

        // FOLDER ZIP EXAMPLE START //



        //Metion your File Path here

        string folderpath = "E:\\test";



         try            

         {

             string fname;

                using (var zip = new ZipFile())

                {

                    //Here i set password property to the zip file

                    zip.Password = "test123";

                    zip.AddDirectory(folderpath);

                    fname = folderpath + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".rar";

                    zip.Save(fname);

                    lblmsg.Text += "Multiple files are zipped here:   " + folderpath + "


";

                }

                // extract entries that use encryption

                using (ZipFile zip = ZipFile.Read(fname))

                {

                    zip.Password = "test123";

                    zip.ExtractAll("extractDir");

                }



              

         }

        catch(Exception ex)

        {

            lblmsg.Text="Error During Multiple file zip operation!";

        }

        // MULITPLE FILE UPLOAD AND ZIP EXAMPLE END //

    }

}



سورس کد با سی شارپ asp.net نوشته شده

پیوستش میکنم :



دانلود :

.rar   ArchieveFileWeb(www.parsicoders.com.rar (اندازه 253.95 KB / تعداد دانلود: 140)