ACCESS
- 来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgAccess
- 最后更新: 2022-03-27
Open 语句的子句,用于指定请求的访问权限
语法
open filename for binary Access {Read | Write | Read Write} as [#]filenum用法
vb
open filename for binary Access Read as #filenum
open filename for binary Access Write as #filenum
open filename for binary Access Read Write as #filenum参数
Read
以只读权限打开文件。
Write
以只写权限打开文件。
Read Write
以读写权限打开文件。
说明
Access 与 Open 语句配合使用,请求读取、写入或读写权限。若未指定 Access 子句,默认为 Read Write。
示例
此示例演示如何以 FreeFile 返回的打开文件号,在 Binary 模式下以 read 访问权限打开 "data.raw",然后以 write 访问权限打开 "data.out"。
start GeSHi
vb
Dim As Long o
'' get an open file number.
o = FreeFile
'' open file for read-only access.
Open "data.raw" For Binary Access Read As #o
'' make a buffer in memory thats the entire size of the file
Dim As UByte file_char( LOF( o ) - 1 )
'' get the file into the buffer.
Get #o, , file_char()
Close
'' get another open file number.
o = FreeFile
'' open file for write-only access.
Open "data.out" For Binary Access Write As #o
'' put the buffer into the new file.
Put #o, , file_char()
Close
Print "Copied file ""data.raw"" to file ""data.out"""
Sleepend GeSHi
与 QB 的差异
- 无已知差异。
另请参阅
OpenReadWrite
返回 目录