I have a folder structure containing a number of documents, as well as a shortcut link to another file in the folder structure. (essentially the file structure maps like a graph). If I zip up these files in Windows, the shortcut will point to the right file when the archive is uncompressed somewhere else.
Now, I want to be able to do this using the System.IO.Packaging stuff... this requires that I put the each file in a stream to tie it to the zip file. The problem is shortcut files (.lnk) apparently aren't actually files (if you do a file.exist on it, its not there). My normal method of...
System.IO.FileStream(shortcut, System.IO.FileMode.Open)
...will not work. So how would I add a shortcut to a zip package?
A ZipPackage isn't a regular Zip file, but a file meant to be used by new Office XML-based file format (docx, xlsx, etc).
If you want to zip something, you should to use another library, like #ziplib
Related
I have developed a C# application in Unity for Android. Additionally, I built a custom external C++ DLL which is properly loaded and accessible from the C# code. I have also added some .xml files into the StreamingAssets folder which works as expected as I can see those files loaded into the .apk.
Currently my problem is that I'm not able to access such xml files from my C++ library. On one hand I'm not sure how to do it correctly, on the other I tried multiple unsuccessful approaches including trying to understand in which cwd was my DLL loaded and then navigate to the files I needed (which didn't work as I constantly receive an access denied error).
EDIT:
Your replies actually put me on the right track and I solved the issue as follow:
During the OnStart() phase of my application, I use the UnityWebRequest class to extract from the JAR file the required files and then I save them in the Application.persistentDataPath
After that, I pass to my DLL the new path to each file which allows me to access them without any issue.
On Android the StreamingAssets are in a jar. That may well be the reason why you can't access them, but as you can see in the manual you can use the WWW class to retrieve files there.
On Android, the files are contained within a compressed .jar file
(which is essentially the same format as standard zip-compressed
files). This means that if you do not use Unity’s WWW class to
retrieve the file, you need to use additional software to see inside
the .jar archive and obtain the file.
(https://docs.unity3d.com/Manual/StreamingAssets.html)
On Android, the files are contained within a compressed .jar file
(which is essentially the same format as standard zip-compressed
files). This means that if you do not use Unity’s WWW class to
retrieve the file, you need to use additional software to see inside
the .jar archive and obtain the file.
A JAR is a package file format typically used to aggregate many Java class files and associated metadata and resources into one file for distribution. JAR files are archive files that include a Java-specific manifest file. They are built on the ZIP format and typically have a .jar file extension.
This means that you can work with jar files the same way as you do with zip files.
There is a fork for minizip with examples on how to use it.
I'm using System.IO and ZipFile, I was wondering if anyone could give me a snippet of code that extracts files from a .zip archive and puts them into a .jar file, or atleast helps get me started with doing something like that.
JARs are ZIPs just with a different extension, just copy and rename the file.
Jar and zip has exactly same format.
You can add meta-inf to that jar if you want to add some manifest (can be done via JarFile etc)
I'm working on an app that needs to save some data and images together into a project file. I assume this project file will have to be some sort of bundle. An example of this would be a project file in Cakewalk SONAR, an audio editor.
To be more precise, I'm working on an application that creates trivia games. When the user exports a game project as the finalized "end product," it will include text and images. This is the "bundle" that I want to create.
You can always save the files to folder and use some archivator like zip with password. And you can rename the file extension to something like .bnd or .prd
File, Save As..., select "Sonar Bundle (.CWB)" as file type.
I have a language file and a settings file of my windows application. This files are in xml format and they are shown in the release folder. I want to hide, crpyt or something like that to that files so users can not see either reach my files.
What is the best way to do this.
how does it fit your needs to simply have another extension instead of .xml so the user does not know how to open the files?
you can also set the files as "Embedded Resource" and load from resource so it will be inside the dll itself instead of being available outside as separate file.
other option is to encrypt the file which could be good as well, up to you.
for a very small file, I would embed it.
In my project i have created a file upload.Now it is required that any exe file or exe file in a zip folder having .zip as extension, be prevented from being uploaded.
Can someoe suggest me a solution?
For each of your task, you have to implement separate algorithm for check.
Check extension before upload (see possible duplicate question)
Check that uploaded zip is really an archive (mime type, libmagic, etc)
Check that uploaded archive doesn't contain exe (unzip it, see previous paragraph)