# How do I find the size of a file?

Hello,
I have a file (“path/to/my/file/myfile”), and I wishes to know its size.

I try

filesize("path/to/my/file/myfile")

but only get 0 in output (which definitely is not its size). How do I get the filesize?

help?> filesize
search: filesize

filesize(path...)

Equivalent to stat(file).size.

If you use stat you can see, if the path is correct:

julia> stat("path/to/my/file/myfile")
StatStruct(mode=0o000000, size=0)

as expected for this example. But for something existing:

julia> stat("c:\\Temp\\Test2.jl")
StatStruct(mode=0o100666, size=296)
2 Likes

Ahh, that is a helpful approach. Thanks, yes, this should do.

1 Like