Actually, you need getFileStatus and fileSize , both from System.Posix (which will work fine on Windows if you use the unix-compat package instead of unix ). Usage is as follows, leaving error handling to your discretion:
getFileSize :: String -> IO FileOffset getFileSize path = do stat <- getFileStatus path return (fileSize stat)
Why is it worth it, and although I think it is less readable, you can shorten this form to:
getFileSize path = getFileStatus path >>= \s -> return $ fileSize s
source share