D
donn
I would like to add new files or replace existing entries as I'm
looping through a directory (folder.) ZipFile.open will open a zipfile
if it exists, or create it if does not. I would like to take the
contents of a folder (fl) and add them to the ZipFile. If the file
already exists in the ZipFile, I would like to replace it. I'm having
trouble keeping all the pieces straight in my head. I'm just not
getting what needs to be done. I'm sure it involves ZipFsFile, but I
don't know how or where to gather the info.
Any advice and guidance is appreciated. Thanks, dvn.
Dir.chdir("#{CmsStandards.psDataDrive}#{@refd}#{@prj.run}\\reports")
fl = Dir.entries('.')
Zip::ZipFile.open("#{lpFolder}\\#{filename}.zip",
Zip::ZipFile::CREATE) {
|zipfile|
puts "Source files from #{Dir.getwd}\n\n"
fl.each {|f|
if File.file?(f)
puts f
zipfile.add(f,f)
end
}
} if !fl.empty?
looping through a directory (folder.) ZipFile.open will open a zipfile
if it exists, or create it if does not. I would like to take the
contents of a folder (fl) and add them to the ZipFile. If the file
already exists in the ZipFile, I would like to replace it. I'm having
trouble keeping all the pieces straight in my head. I'm just not
getting what needs to be done. I'm sure it involves ZipFsFile, but I
don't know how or where to gather the info.
Any advice and guidance is appreciated. Thanks, dvn.
Dir.chdir("#{CmsStandards.psDataDrive}#{@refd}#{@prj.run}\\reports")
fl = Dir.entries('.')
Zip::ZipFile.open("#{lpFolder}\\#{filename}.zip",
Zip::ZipFile::CREATE) {
|zipfile|
puts "Source files from #{Dir.getwd}\n\n"
fl.each {|f|
if File.file?(f)
puts f
zipfile.add(f,f)
end
}
} if !fl.empty?