Can some body help me what is wrong with my program. When i tried to run following program, I am getting the following error message:
hSetFileSize
: invalid argument (Invalid argument)
import System.IO
main = do
putStrLn "Enter file name (Including full path) to read"
fileName <- getLine
handle <- openFile fileName ReadMode
sizeBeforeTrunc <- hFileSize handle
content <- readFile fileName
putStrLn $ "Size of the file Before truncation is " ++ (show sizeBeforeTrunc) ++ " bytes"
putStrLn $ "Content of the file is " ++ content
putStrLn "**************************************"
let n = sizeBeforeTrunc `div` 2
putStrLn $ "Truncating file to " ++ (show n) ++ " bytes"
info1 <- hSetFileSize handle (toInteger 10)
putStrLn $ show info1
sizeAfterTrunc <- hFileSize handle
putStrLn $ "Size of the file After truncation is " ++ (show sizeAfterTrunc) ++ " bytes"
putStrLn $ "Content of the file is " ++ content
hClose handle