How to zip an access database file
Mobile Development. Software Development. Remote Development and Debugging Tools. Nested class structure question. How to use Nuget assembly as files with visual studio community. Follow us! Get the Latest Bytes Updates. By using this site, you agree to our Privacy Policy and Terms of Use. Robert This is an easy question, but I 've never done it before.
Robert Nov 12 '05 Pete Cresswell As others have said General lancet: a comprehensive, efficient, and reusable util function library of go reply views Thread by lanliddd last post: by.
Why does every database engine do this? It's useless and downright dangerous when it actually kicks in. For a single user, you can just compact as needed. That's all I can think of regarding compact for now.
Nice post, even though your answer feels like killing a fly with a bazooka. Heh, yes, I guess. This just gets it all down in one place, more or less, and, I hope, people can be pointed to it when needed, instead of others having to answer questions on the subject piecemeal.
I like writing answers like this, since it helps me understand what I do and don't know. I hope it also helps others sometimes. Open the mdb and do a 'Compact and Repair'.
This will reduce the size of the mdb. You can also set the 'Compact on Close' option to on off by default.
Edward Leno Edward Leno 6, 3 3 gold badges 32 32 silver badges 48 48 bronze badges. How did you understand that? I had the same exact problem 10 years ago Which version of Microsoft Access do you have? Setting "Compact On Close" is not recommended as occasionally it has been known to have a problem and lose data.
Documentation: Pages on microsoft. Dispatch 'DAO. Leonhard M. Leonhard 10 10 silver badges 16 16 bronze badges. Community Bot 1 1 1 silver badge. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Helping communities build their own LTE networks. Podcast Making Agile work for data science. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.
Linked Related The reason for introducing varZipFIle into that code is that, for reasons I haven't bothered to determine, the name of the zip file must be stored in a variant in order to use it as the NameSpace. If you try to use a string variable instead, you'll end up getting an error 91 "Object variable or With block variable not set". You may be wondering about the reference to GoToSleep in that code. GoToSleep is a bit of code that uses the Sleep API to pause execution for the number of milliseconds specified and then continue execution, shown in Sample 3.
The reason for including it is that, depending on the size of the files being added, compressing can take an appreciable time. Realistically, it's simply a bit of a kludge to ensure that we wait until compressing is done. Sample 3 — The GoToSleep routine that pauses execution for a given number of milliseconds. Adding multiple files to the Zip file is easy too. For instance, if you wanted to add all of the files in a given folder to your Zip file, you can use the Dir function to retrieve the details of each file in a given folder.
Once you know each file, you can add each one to the Zip file. Sample 4 shows the modifications required to the code presented in Sample 2 to do this. Note that this does not add files in subfolders.
Sample 4 — The code required to add all files in a folder to a new Zip file. In actual fact, it's not necessary to use a new Zip file each time. Sample 5 shows how to change Sample 2 to accommodate existing Zip files. Sample 5 — The code required to add a single file to either a new or existing Zip file.
Since, as previously mentioned, the Zip file is treated as a Folder by Windows Shell, listing the files contained within it is straight-forward as well: the GetDetailsOf method of the Folder object will give you the information you need. MSDN says a value of 1 for iColumn will retrieve the size of the item, a value of 2 will retrieves the type of the item and a value of 3 will retrieve the date and time that the item was last modified.
I also found that a value of 6 will retrieve the details of the ratio of packed to unpacked, while a value of 8 will retrieve the CRC value of the file. The code shown in Sample 6 will write the details of each file to the Immediate window. Sample 6 — Code to list details of files contained in a Zip file. Extracting the files to a known location is straight-forward as well. You can instantiate a Folder object representing the destination to which you want the files unzipped, and then use the CopyHere method to copy the files from the Zip file to that location.
Sample 7 illustrates this. Sample 7 — Code to unzip all files in a Zip file. For more granularity, you can use the technique shown in Sample 6 to get the details of which files are contained in the Zip file, and then use the name of the specific file s you want unzipped with the CopyHere method.
If you only want to unzip a specific file, you'd replace the line of code. As mentioned, I've only just scratched the surface of working with the Windows Shell in this article. Yes, it's a little clunky. As far as I'm aware, there isn't a method to delete files from a Zip file you'd need to create a new Zip file, copy the files you don't wish to delete from the existing Zip file to the new Zip file, delete the existing Zip file then rename the new Zip file.
However, if what you're trying to do is add the ability to zip files from within your application perhaps because you want to e-mail them as attachments , this technique is certainly simple to add. One form frmAddToZip allows you to specify a file into which other files should be compressed as well as specify which file s should be zipped into that file. I've included code to invoke the standard Windows File Open dialog to let you select the Zip file which, by the way, does not have to already exist , or you can simply type the file name into the text box.
You can invoke the dialog either by clicking on the button to the right of the text box, or by double-clicking on the text box itself. To select the files to add to the Zip file, though, I believe you must use the File Open dialog which, again, you can invoke either by clicking on the button to the right of the large text box, or by double-clicking on the text box itself.
That's the reason why I'm not sure it'll work if you simply type the file names into it. If you type the name in, you'll need to hit Enter once you're done in order to invoke the AfterUpdate event. Once you've provided the path to the zip file, the details of the files within that zip file will appear in the List View control below. If you also specify a folder to which to unzip the file either by typing it into the text box, or by invoking the standard Windows Browse Folder dialog by using the button or double-clicking , you'll be given the option to unzip all of the files to that location.
0コメント