open()

描述

开启 MicroSD 卡上的档案。如果档案开启的模式是写入,而指定的档案不存在,则会建立该档案,但是存放该档案的资料夹必须已经存在。

语法


SD.open(filepath)
SD.open(filepath, mode)

参数

filename:要开启的资料夹路径,路径应该要以 “/” 分隔资料夹名称,型态为 char*
mode (非必要):开启档案的模式,可以为以下之一,如果没有提供这个参数,预设为 FILE_READ
FILE_READ:开启档案后可以读取资料,起始位址为档案的开头
FILE_WRITE:开启档案后可以写入以及读取资料,起始位址为档案的结尾

回传

File:如果档案开启成功回传一个指向该档案的 File 物件,如果开启失败则该 File 物件在使用 if 判断时与布林值的 false 相等

See also

File: close()


函式库参考主页面

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.