Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Zipping Files from the web

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19514 |

    Hi there,

    I’m wondering what will be the best way to zip some files up via the web. Essentially I have a page that will allow a user to select some documents and then allow the user to download a zip of all of those documents.

    Currently all documents sit on a non-web accessable RAID drive, but the webserver has access too. I’ve been playing around with QuickZip to do this, but I always get a “there was an error” which really doesn’t help me much. When I use the QuickZip.Zip option, I give it the path and file name of the empty text file I renamed to “something.ZIP” and then pass it a string array as suggested. Thats about as far as I get.

    Anyone have a good suggestion on how to possibly do this, or am I using the wrong tools completely.

    Thanks in Advance for your help

    I’m using VS 2005 C# .NET 2.0 Release

    Imported from legacy forums. Posted by XanthViper (had 4244 views)

    User (Old forums)
    Member
    Post count: 23064

    You inspired me a <a href=”http://blogs.xceedsoft.com/plantem/PermaLink,guid,e89375a1-63e3-470f-b804-28ef40192554.aspx”>more precise blog post</a> about the subject. Hope this helps.

    Imported from legacy forums. Posted by Martin (had 344 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Martin,

    Thank you for the example. It does give me a new way to look at doing this. I am curious though, how would you go about adapting this to this being used with a object?

    Meaning I have an assembly that will have a method that will create the zip file as I pass in, say one files path. That way I can just return the path as to where the file was saved at.

    I think in your example, we are trying to force the zip file down to the user which is good, but in my case I’m bound by a business rule to not allow that to happen. Considering I would like to call this from multiple places, having a method in a referenced assembly for my website is perfect.

    Thanks for your time.

    Charlie

    Imported from legacy forums. Posted by XanthViper (had 325 views)

    User (Old forums)
    Member
    Post count: 23064

    BTW, here is what I am currently working with, mind you it is still rough (and don’t laugh at my random file name creator 😀 ):

    public string CreateDownloadPackage(int userID, string docList)
    {

    Tools ArchTool = new Tools(ModuleSettings.ConnectionString);

    //ok, first we need to create a folder to zip up on the thumbs directory

    //Generate Random Folder Name
    //Folder name will be date time stampe + userid
    string ZipSavePath = ModuleSettings.DocThumbFilePath;
    string ZipFolderName = DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + “_” + userID.ToString();
    string ZipFileName = DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + “_” + userID.ToString() +”.zip”;

    if (Directory.Exists(ZipSavePath + ZipFolderName) == false)
    Directory.CreateDirectory(ZipSavePath + ZipFolderName);

    //now let’s create the actual zip file
    File.Create(ZipSavePath + ZipFolderName + “\\” + ZipFileName);

    //ok, now we need to loop through each document, get it’s path, and copy it to the save place

    //Get an array of the DocID’s
    string[] SplitDocIDs = docList.Split(new Char[] { ‘~’ });

    string[] DocsToBeZipped = null;
    int DocCounter = 0;

    DocsToBeZipped = new string [SplitDocIDs.GetUpperBound(0)];

    for (int i = 0; i < SplitDocIDs.GetUpperBound(0); i++)
    {

    if (ArchTool.IsFlagSet((DocumentFlags)(ArchTool.GetDocumentFlag(SplitDocIDs[i])), DocumentFlags.LocalUseAndPrint) == true)
    {
    <b> //here is where we will create a string array of all documents that need to be zipped. //This will return the full path of the file
    DocsToBeZipped[DocCounter] = GetDocOriginalFilePath(SplitDocIDs[i].ToString());</b>
    DocCounter++;
    }

    }

    //ok, now we have moved all of the files, let’s do some “ZIPPING”
    <b>
    Xceed.Zip.Licenser.LicenseKey = ModuleSettings.XCEEDLicenseKey;
    QuickZip.Zip( ZipSavePath + ZipFolderName + “\\” + ZipFileName, DocsToBeZipped);
    </b>

    //clean up objects
    ArchTool = null;

    //ok, all is good, so let’s return the webpath of the file

    string RetString;

    RetString = ModuleSettings.DocThumbWebURL + “\\” + ZipFolderName + “\\” + ZipFileName;

    return RetString;

    }

    Imported from legacy forums. Posted by XanthViper (had 463 views)

    User (Old forums)
    Member
    Post count: 23064

    And finally, here is the exception I get when the QuickZip.Zip is rung:

    <b>An error occurred while adding files to the zip file.</b>

    Ok..i’m done posting. Hopefully someone can point me in the right direction here.

    Imported from legacy forums. Posted by XanthViper (had 348 views)

    User (Old forums)
    Member
    Post count: 23064

    bump…

    Imported from legacy forums. Posted by XanthViper (had 5184 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.