Ejemplo n.º 1
0
        void GenerateJarFile(string jarFilePath, IEnumerable <string> files)
        {
            if (File.Exists(jarFilePath))
            {
                File.Delete(jarFilePath);
            }

            if (!Directory.Exists(Path.GetDirectoryName(jarFilePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(jarFilePath));
            }


            JarFileFactory jarFactory = new JarFileFactory();

            Dictionary <string, string> header = new Dictionary <string, string>();

            using (var jarFileWriter = jarFactory.GetJarFileWriter(jarFilePath))
            {
                foreach (var file in files)
                {
                    header["FileName"] = Path.GetFileName(file);
                    var fvi = FileVersionInfo.GetVersionInfo(file);
                    header["version"] = fvi.FileVersion;

                    jarFileWriter.AddFile(new FileSystem.JarFileItem(header, file));
                }
            }
        }
Ejemplo n.º 2
0
        static void Main12(string[] args)
        {
            var dir         = Path.Combine(RuntimeHelper.ExecutionLocation, "Jar");
            var jarFilePath = Path.Combine(dir, "Include.jar");

            if (File.Exists(jarFilePath))
            {
                File.Delete(jarFilePath);
            }


            JarFileFactory jarFactory = new JarFileFactory();

            var files = Directory.GetFiles(dir);
            Dictionary <string, string> header = new Dictionary <string, string>();

            using (var jarFileWriter = jarFactory.GetJarFileWriter(jarFilePath))
            {
                foreach (var file in files)
                {
                    header["FileName"] = Path.GetFileName(file);
                    var fvi = FileVersionInfo.GetVersionInfo(file);
                    header["version"] = fvi.FileVersion;

                    jarFileWriter.AddFile(new FileSystem.JarFileItem(header, file));
                }
            }
        }