Page 1 of 1

How to get the file size

Posted: Tue Nov 28, 2017 8:03 am
by cagiva
Does MicroPython have a method to obtain the size of a file like os.path.getsize(filename)?

Re: How to get the file size

Posted: Tue Nov 28, 2017 11:12 am
by deshipu

Re: How to get the file size

Posted: Tue Nov 28, 2017 2:29 pm
by Roberthh
That's ok, but Micropython does not support symbolic field names.

Code: Select all

import uos
info = uos.stat("filename")
filesize = info[6]

Re: How to get the file size

Posted: Tue Nov 28, 2017 5:29 pm
by cagiva
That's exactly what I was looking for. Thank you, both.