I've successfully created folders and files inside a ZIP file with QuaZIP, but to create a folder i used a not elegant way, that creates a file without name inside the ZIP file. Is there any way to create empty folders inside a ZIP file without create a file inside that folder?
Code to create folder:
QuaZip zip("path_to\\zipFile.zip");
zip.open(QuaZip::mdCreate);
QuaZipFile outFile(&zip);
outFile.open(QIODevice::WriteOnly, QuaZipNewInfo("SomeFolder\\"));
outFile.close();
Related
Is there a command to copy a folder including all its subfolders with files to other directory? I dont want to create the new directories and then using copy.file to move the files, Id like to make it faster.
location_folder ="path1"
new_location = ="path2"
name_folder="folder"
I want to generate a .zip file which contains some files and folders. The file inside the folder might be contained in some other paths and I want to put files in another folder and generate a .zip file from them.
By other words, I don't want to physically generate the folder with files. The files might be on some roots and I want to generate folder virtually to put them on the .zip file.
Imports System.IO.Compression
ZipFile.CreateFromDirectory("source","destination.zip",CompressionLevel.Optimal,False)
As an example if I have these files on my website:
- ~/files/image/1.jpg
- ~/files/pdf/2.pdf
- ~/intro.docx
I want to put them on a zip which when I extract it, the files will be as follows:
- ~/files/1.jpg
- ~/files/2.pdf
- ~/intro.docx
For the source put the root folder and it will do it
example :
This is yours
- ~/files/image/1.jpg
- ~/files/pdf/2.pdf
- ~/intro.docx
But before this there is a root folder whic is the ~ just simpily put as a source
I want to create a template that creates a project in RStudio with a few non-empty .R files and a directory.
So for example, I create a project named 'project1', I want it to create a regular project, with 3 .r files and a sub-directory.
So my project is located at ~/Desktop/MyProject/
and in this folder I'll have 3 files named file1.r, file2.r, file3.r and a directory called 'data'.
And also, in file1.r there will be the line library(ggplot2).
I've tried reading the project template documentation written here but I got lost a bit.
I created a jar file from a Java project. I can even run it now, but it does not save the serialization file that is stored correctly when I run the program from normal binary code outside of the JAR file.
Can’t you create new files when you have a jar file?
This is how I write the file:
FileOutputStream fileOut = new FileOutputStream("data/vocabulary.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(this);
out.close();
fileOut.close();
My JAR file looks like this:
META-INF
MANIFEST.MF
name
stefankoch
…
where name/stefankoch/… is my project namespace.
I tried creating a data directory in the jar-file (root), but it did not work either. There also is a data directory within the directory the jar-file resides in, but that one is not taken either.
How can I allow jar files to create files?
basically, you should not add information entered by the user into a JAR file, they belong to the user’s home directory.
This can be read with
System.getProperty("user.home")
And files within the user home directory can also be used from within a JAR file.
If you have files in the build/classes/folderToJar Netbeans7 takes the .class files and make a .jar file when you take Clean and Build.
But how can you have .java files and .html files go into the .jarfile as well?
First Create a package(Say html) under Source Packages
copy all of your html files to this package(when you create a package,a folder in the name of your package will be created inside your project src folder, so copy files to it)
You can access your html file from your program as
URL someURL = yourclass.class.getResource("/html/yourhtml.html");