Skip to content

ACCESS


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

以读写权限打开文件。

说明

AccessOpen 语句配合使用,请求读取、写入或读写权限。若未指定 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"""

  Sleep

end GeSHi

与 QB 的差异

  • 无已知差异。

另请参阅

  • Open
  • Read
  • Write

返回 目录

基于 FreeBASIC 官方文档翻译 如有侵权请联系我们删除
FreeBASIC 是开源项目,与微软公司无隶属关系