How to get the file size

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
cagiva
Posts: 22
Joined: Wed Dec 14, 2016 4:49 pm

How to get the file size

Post by cagiva » Tue Nov 28, 2017 8:03 am

Does MicroPython have a method to obtain the size of a file like os.path.getsize(filename)?


User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: How to get the file size

Post by Roberthh » Tue Nov 28, 2017 2:29 pm

That's ok, but Micropython does not support symbolic field names.

Code: Select all

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

User avatar
cagiva
Posts: 22
Joined: Wed Dec 14, 2016 4:49 pm

Re: How to get the file size

Post by cagiva » Tue Nov 28, 2017 5:29 pm

That's exactly what I was looking for. Thank you, both.

Post Reply