Here’s the code :
Dir.foreach('C:\\Documents and Settings\\') { |entry|
if File.directory?( entry )
puts entry
end
}
Dir.foreach('\\\\10.80.14.20\\transfer') { |entry|
if File.directory?( entry )
puts entry
end
}
Both C:\\Documents and Settings and \\10.80.14.20 contain directories. But it only lists the folders under C:\Documents and Settings. While the folders under \\\\10.80.14.20 isn’t listed. It seems File.directory?( entry ) cannot work under shared folders. Am I right? If so, is there any other methods to identify folders when under shared folders?
map
\\10.80.14.20\transferas a separate drive sayF:on your machine where you’re trying to run this program and then modify your code toHowever if you intend to run such code as a windows service, then you’ll have to map the drive from within your code because windows services don’t recognize externally mapped drives.