From: Rob Pa Date: 2011-03-15T04:11:27+09:00 Subject: Splitting up and Reassembling A File Hi, I was wondering if you possibly help? I am looking to split up a file, say an image file, and then at a later date reassemble all of the pieces of this split file to recreate the image. I have implemented this so far; file = File.open("image.jpg","rb"){|f|f.read} i = 1 file.bytes.each_slice(10000) do |slice| new_file = File.new("file_#{i}.txt", "w+") new_file.puts(slice.pack('C*'))) i = i + 1 end I think this is the right logic to split up a file, storing the bytes into a text file name file_1.txt, file_2.txt etc based on the size of the file. To recreate the file I am thinking of doing something along the lines of; new_file = File.new("image_recreated.jpg", "wb+") #for each split up file do |n| file = File.open("file_#{n}.txt","rb"){|f|f.read} new_file.puts(file) end When testing it, the new image_recreated file gets created however is not accessible to view. I hope someone could possibly help. Thanks a lot -- Posted via http://www.ruby-forum.com/.