Monday, 25 July 2016

Ruby small programs

File Inquiries:



--------------------------------------------------------------------------------------
if (File.file?("inputt.txt"))
puts "yes"

else
puts "no"
end

--------------------------------------------------------------------------------------------

if (File.file?("input.txt"))
puts "File exist"

else
puts "File not exist"
end


 size=File.size?("input.txt")
 puts "File size is #{size}"


--------------------------------------------------------------------------------------------
print "present directory is: " 
 puts Dir.pwd


  
print "files in directory"
 puts Dir.entries("C:/Users/mobigesture/rubyscript")



--------------------------------------------------------------------------------------------
 #puts Dir.entries("C:/Users/mobigesture/rubyscript")
 
 puts "Files in the directory"
 Dir.foreach("C:/Users/mobigesture/rubyscript") do |fname|
 puts fname
 end

--------------------------------------------------------------------------------------------





--------------------------------------------------------------------------------------------



--------------------------------------------------------------------------------------------

No comments:

Post a Comment