“Salinan File Ruby” Kode Jawaban

File Salin Ruby

my_dir = Dir["C:/Documents and Settings/user/Desktop/originalfiles/*.doc"]
my_dir.each do |filename|
  name = File.basename('filename', '.doc')[0,4]
  dest_folder = "C:/Documents and Settings/user/Desktop/destinationfolder/#{name}/"
  FileUtils.cp(filename, dest_folder)
end
MXO

Salinan File Ruby

file = File.open('text.txt', 'r')            # Opening file
copied_file = File.open('new_text.txt', 'w') # Creating new file
copied_file.puts(file.read)                  # Copying file
#                     Closing files
file.close
copied_file.close
#                        Testing
copied_file = File.open('new_text.txt', 'r') # Opening copied file
puts(copied_file.read)
# => What markets are called black? Those in Africa!
weegee

Jawaban yang mirip dengan “Salinan File Ruby”

Pertanyaan yang mirip dengan “Salinan File Ruby”

Lebih banyak jawaban terkait untuk “Salinan File Ruby” di Ruby

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya