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.


์ฐธ๊ณ  ํ•ญ๋ชฉ: Open

Syntax:


  FileAttr (Channel As Integer, Attributes As Integer)

Return value:

Integer

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๋กœ ์ง€์ •ํ•  ๊ฒฝ์šฐ ๋‹ค์Œ์˜ ๋ฐ˜ํ™˜ ๊ฐ’์ด ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

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

Please support us!