c# - Zip file from URL not valid -
i followed post able zip content of url..
when click button download, "zip" content of url , save in default download folder...
so far code:
webclient wc = new webclient(); zipfile zipfile = new zipfile(); string filename = "myfile.zip"; zipfile.password = item.password; stream s = wc.openread(myurl); zipfile.addeentry(filename, s); homecoming file(s, "application/zip", filename); it´s similar 1 (which zips content of folder... ) (it works correctly)
zipfile zipfile = new zipfile(); zipfile.password = item.password; zipfile.adddirectory(sourcepath, ""); memorystream stream = new memorystream(); zipfile.save(stream); zipfile.dispose(); stream.seek(0, seekorigin.begin); homecoming file(stream, "application/zip", filename); so, want same url..
thanks!
the illustration provide create entry within zip file contents stream doing nil save , homecoming actual zip file. need utilize creation code sec example.
// name of zip file string filename = "myfile.zip"; // filename of content string contentname = "mypage.html"; webclient wc = new webclient(); zipfile zipfile = new zipfile(); zipfile.password = item.password; stream s = wc.openread(myurl); zipfile.addeentry(contentname, s); memorystream stream = new memorystream(); zipfile.save(stream); zipfile.dispose(); // utilize using instead s.dispose(); // utilize using instead.... stream.seek(0, seekorigin.begin); homecoming file(stream, "application/zip", filename); this homecoming zip file 1 file in called content.html containing contents of url stream
c# webclient dotnetzip
No comments:
Post a Comment