04-17-2013 05:03 PM
How can I add a folder to a zip file. What I want is to create a txt file, which I place in a regular folder, then place the regular folder in a zipped folder. They all (folder, file , and zip) need to be the same name also, so the directory would be as an example C:\Desktop > runner.zip > runner > runner.txt or something similar. So far I can create a zip file, and I can create a regular folder and place the txt document in the regular folder, but i cannot seem to be able to put the regular folder in the zip folder. I get an error saying: "LabVIEW: An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @." It creates the zip file, and also the other folder with the txt file in it, but it wont put the regular folder in the zip file.
Thanks ahead of time
04-17-2013 06:47 PM - edited 04-17-2013 06:51 PM
The "source file path" input into the zip-file VI should be the full path to the file, the "destination path in zip" should be the relative path for that file within the zip file, so a path equivalent to runner\runner.txt
You could either make this manually in a string and use string->path, or use a combination of strip path, build path and string to path to work it out automatically from the file output when you define the file to zip.
There's a fully fledged example at labview\examples\file\Zip Tool.llb
or the block diagram below might help
Normal warning: This is not set up to prevent overwriting existing files.
04-17-2013 08:44 PM
I have been messing with this code and it gives me the same thing. It just gives a zip file with the text file inside of it. I need a text file inside of a folder inside of zip file
04-17-2013 09:07 PM
@lvuser333 wrote:
I have been messing with this code and it gives me the same thing. It just gives a zip file with the text file inside of it. I need a text file inside of a
folder inside of zip file
It's working for me.
Is the file you want to zip in a folder with the name you want (in the zip file) already?
04-17-2013 10:21 PM
are you using the example file or the same code as the above screen shot? So i think my problem is I have been trying to addd the folder to a zip file I created, whereas I think that if I just zip up the folder that has the txt file in it, I will then have a zip file which contains a folder which contains the txt file, is this correct?
04-17-2013 11:20 PM - edited 04-17-2013 11:24 PM
@lvuser333 wrote:
are you using the example file or the same code as the above screen shot? So i think my problem is I have been trying to addd the folder to a zip file I created, whereas I think that if I just zip up the folder that has the txt file in it, I will then have a zip file which contains a folder which contains the txt file, is this correct?
I'm using the code in the screenshot (I whipped up the example quickly to see if I could get it to work, so it probably isn't the best or cleanest way to do it).
[The example code from NI should work, but is probably more than you need].
You zip files, but you tell the VI which folder within the zip file (i.e. relative to the zip file) you want them to go in.
Just like how you might have a folder tree on your C drive
animals
->mammals
---->four_legs
-------->delicious
-------->thinks_you_are_delicious
---->two_legs
->birds
---->can_fly
---->cannot_fly
->fish
---->salt_water
---->fresh_water
You can have the same structure in the zip file.
For instance a photo of a flathead (a type of salt water fish)..
the file might be flathead.jpg with the path within the zip would be fish\salt_water\flathead.png
on the other hand a tiger photo
the file would be tiger.png but the path would be mammals\four_legs\thinks_you_are_delicious\tiger.png
04-18-2013 12:28 AM
@Hornless.Rhino wrote:
the file might be flathead.jpg with the path within the zip would be fish\salt_water\flathead.png
of course both of those should have had the same extension 🙂
04-22-2013 11:43 AM
i think I tried everything that you guys said but I still cannot seem to get it. I tried the original screenshot you posted but I want to create the files also and not have the user pick them. I attached a code i wrote up, i am getting duplicate path name errors and also when I run the code (depending on how I wire it) i can get a folder, text file, and zip file, but they are not all within eachother.
04-22-2013 11:48 AM
"You zip files, but you tell the VI which folder within the zip file (i.e. relative to the zip file) you want them to go in.
Just like how you might have a folder tree on your C drive"
- i understand that you zip files, but how can i tell the vi which folder within the zip file to go into if I cannot put any files in my zip file in the first place??
04-22-2013 02:06 PM
You have a problem when you are moving your text file. Your destination path should include the file itself, not just the folder to put it in. Use the same constant that you are using for the add to zip file's source path.