locked
Remove full path in the zip file RRS feed

  • Question

  • User364663285 posted

    Hi,
    Using these codes

                        ZipFile newFile = new ZipFile();
                        newFile.Password = "1234";
                        newFile.AddFile(Server.MapPath("~") + "\\..\\xml\\common.xml");
                        newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip");
    



    the zip file is created with the full path. How to make it only save the xml file inside the zip file?

    Wednesday, June 26, 2013 9:26 AM

Answers

  • User-2001332922 posted

    newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip")

    please tell is Remove method return void as error then

    newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip".Trim("~\\..\\xml\\"));

    Or

    newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip").Trim(indexof(0,n));

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 27, 2013 9:51 AM

All replies

  • User-2001332922 posted

    unsure that is yes the respose is doubtedly

    newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip").Remove("~\\..\\xml\\");

    Wednesday, June 26, 2013 10:09 AM
  • User364663285 posted

    Then I get error which is

    Error    1    Operator '.' cannot be applied to operand of type 'void'    C:\App10\App10\Default.aspx.cs    131    21    App10

    due to this

                        newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip").Remove("~\\..\\xml\\");
    



    Wednesday, June 26, 2013 11:08 AM
  • User-2001332922 posted

    newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip")

    please tell is Remove method return void as error then

    newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip".Trim("~\\..\\xml\\"));

    Or

    newFile.Save(Server.MapPath("~") + "\\..\\xml\\zipfl.zip").Trim(indexof(0,n));

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 27, 2013 9:51 AM