-
Jun 9th, 2021, 06:57 PM
#1
Thread Starter
Banned
zipping a complete folder
I'm trying to zip a folder and its contents. Using
Code:
ZipFile.CreateFromDirectory("source", "destination.zip")
zips the contents but not the containing directory.
How can I achieve this? Note: I don't want to zip all the folders where the source folder is.
For example...
In .minecraft/saves, I want to backup "World_A" including the folder, so that when opening the zip file with an archiver such as 7Zip or WinRAR, you first see the folder still containing the "World" data.
What I have tried:
Nothing I have searched on Google and various programming sites such as this one even mentions this issue.
If I try adding the directory name to the zipfile name, it gives a file not found error.
-
Jun 9th, 2021, 08:09 PM
#2
Re: zipping a complete folder
There really is no excuse for you to not have been able to work this out for yourself. The method you're calling is overloaded and allows you to specify whether the base directory should be included. Intellisense would have shown you that as you typed your code. Even if you missed that, it's in the documentation and reading the relevant documentation should be the very first thing you do when you have a problem with a specific type or member. You should have a link to the documentation home page on your browser's favourites bar but, even if you don't, you can get there from the VS Help menu or directly to a type or member by clicking it and pressing F1. ALWAYS read the documentation first. RTFM is a cliche for a reason.
For the record, I didn't know the answer to your question as I've never used that ZipFile class but I went straight to the documentation and there it was. A few seconds work that takes no programming experience at all. There are things that are hard to work out and there are things that are easy. This was the latter.
-
Jun 9th, 2021, 08:17 PM
#3
Thread Starter
Banned
Re: zipping a complete folder
No there isn't and as I said, I searched for such documentation and none exist.
Thanks for nothing. Again.
-
Jun 9th, 2021, 08:33 PM
#4
Re: zipping a complete folder
Originally Posted by Amerigoware
No there isn't and as I said, I searched for such documentation and none exist.
Thanks for nothing. Again.
Yes, there is. I found it within seconds as well. I would help you out by posting the link to said documentation but since it doesn't exist that might create some sort of forum vortex that destroys the universe.
You're welcome for my nothing.
Edit: I'm feeling charitable and in the mood for universe-destroying risk. This big old rock has pretty much run its course anyway.
https://docs.microsoft.com/en-us/dot...y?view=net-5.0
Last edited by OptionBase1; Jun 9th, 2021 at 08:40 PM.
-
Jun 9th, 2021, 09:04 PM
#5
Re: zipping a complete folder
Originally Posted by Amerigoware
I searched for such documentation and none exist.
So you're saying that the documentation that I read with my own two eyes before submitting my previous post actually doesn't exist? That's really what you're telling me? Why were you "searching" for documentation anyway? Documentation is not just any old information posted by any old person. It is official reference material written by Microsoft to help the likes of you, but all too often the likes of you just ignore the thousands of hours spent compiling it. There's no searching required, as I already posted. You can get there from the Help menu in VS and clicking a type or member in the code window and pressing F1 will take you straight to the page for that type or member. Help menus and context-sensitive Help have been things in Windows for decades so, again, no excuse. If you want to write software then you ought to know how to use software. Making mistakes is one thing but denying them when they're pointed out is just compounding the error. Telling people that what they just read doesn't actually exist doesn't help your cause and it won't help you fix future errors or avoid wasting time searching for information that you can click straight to.
-
Jun 9th, 2021, 09:33 PM
#6
Thread Starter
Banned
Re: zipping a complete folder
Ok, I didn't know about the f1 thing. Using help and searching didn't come up with an answer. Perhaps not the correct search terms. IDK.
Anyway, unlike you, I've never had a lesson in programming or all the visual studio functions. I don't appreciate being treating like an idiot. When I say I've searched for something, I mean it. (not that I should need to because that's what forums like this exist for.)
Also, when searching on Microsoft, or clicking search result links to Microsoft docs, it's almost always useless info listing methods and overloads without any example of how to use them. Often when it does, it's only in C#. (yes, I can translate(usually). The same when clicking on the 'help' button when getting an error (if not a page saying no info available).
Anyway, my point is, we're not all pros, and if you can't RESPECTFULLY give an answer, link, or proper search query, then please don't respond at all. Thank you.
-
Jun 9th, 2021, 09:48 PM
#7
Re: zipping a complete folder
What were you searching Google for? It should be as succinct and specific as possible. In this case, all you should have searched for was "ZipFile.CreateFromDirectory". Nothing more than that. Do you see the pattern there? If you are having trouble with code using class.method(parameters), then just Google search for class.method.
Don't fall into the trap thinking that Google works best when you put in a search like "How to get my Visual Basic program to include all files from the base directory when creating a zip file"
-
Jun 9th, 2021, 09:52 PM
#8
Re: zipping a complete folder
Originally Posted by Amerigoware
Anyway, unlike you, I've never had a lesson in programming or all the visual studio functions.
Like I said, Help menus and context-sensitive Help have been a thing in Windows for decades. VS works exactly like so many other Windows programs.
Originally Posted by Amerigoware
Anyway, my point is, we're not all pros
My point is that you don't need to be a pro. You just need to have used Windows software.
Originally Posted by Amerigoware
Also, when searching on Microsoft, or clicking search result links to Microsoft docs
So you actually have already used the documentation so you know it exists, but you claimed it didn't. You also chose not to use it because it might not answer the question, but it did. Do you have any more excuses or will you just read the documentation first in future and then look elsewhere only if you need to?
Originally Posted by Amerigoware
I don't appreciate being treating like an idiot.
I could recommend a way to minimise the chance of that happening.
-
Jun 11th, 2021, 06:38 AM
#9
Hyperactive Member
Re: zipping a complete folder
To add to this lovely debate, you can easily change the code from C# to VB.NET by clicking the language button “</>” up at the top of the page. No more translation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|