FileAttr Function

ត្រឡប់​របៀប​ដំណើរ​ការ ឬ​លេខ​ដំណើរ​ការ​ឯកសារ​នៃ​ឯកសារ​មួយ​ ដែល​ត្រូវ​បាន​បើក​ជាមួយ​សេចក្តី​ថ្លែង​ការណ៍ Open ។ លេខ​ដំណើរ​ការ​ឯកសារ​គឺ​ពឹងផ្អែក​លើ​ប្រព័ន្ធ​ប្រតិបត្តិ​ការ (OSH = Operating System Handle) ។

រូប​តំណាង​ចំណាំ

If you use a 32-Bit operating system, you cannot use the FileAttr function to determine the file access number.


មើល​ផង​ដែរ ៖ បើក

Syntax:


  FileAttr (Channel As Integer, Attributes As Integer)

Return type:

ចំនួន​គត់

Parameters:

Channel: The number of the file that was opened with the Open statement.

Attributes: Integer expression that indicates the type of file information that you want to return. The following values are possible:

1: FileAttr indicates the access mode of the file.

2: FileAttr returns the file access number of the operating system.

ប្រសិន​បើ​អ្នក​បញ្ជាក់​​​គុណ​លក្ខណៈ​ប៉ារ៉ាម៉ែត្រ​ជាមួយ​តម្លៃ ១ តម្លៃ​ត្រឡប់​ខាង​ក្រោម នឹង​អនុវត្ត ៖

1 - INPUT (បើក​ឯកសារ សម្រាប់​បញ្ចូល)

2 - OUTPUT (បើក​ឯកសារ សម្រាប់​បង្ហាញ)

4 - RANDOM (បើក​ឯកសារ សម្រាប់​ចូល​ដំណើរការ​ចៃដន្យ)

8 - APPEND (បើក​ឯកសារ សម្រាប់​បន្ថែម​ខាង​ចុង)

32 - BINARY (បើក​ឯកសារ​ក្នុង​របៀប​គោល​ពីរ) ។

Error codes:

5 ការ​ហៅ​បែបបទ​មិន​ត្រឹមត្រូវ

52 ឈ្មោះ ឬ​លេខ​ឯកសារ​មិន​ត្រឹមត្រូវ

Example:


Sub ExampleFileAttr
    Dim iNumber As Integer
    Dim sLine As String
    Dim aFile As String
    aFile = "C:\Users\ThisUser\data.txt"
    iNumber = Freefile
    Open aFile For Output As #iNumber
    Print #iNumber, "This is a line of text"
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub