| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>CloseDir filehandle</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- filehandle = valid filehandle assigned from the ReadDir command
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- Once you are finished with NextFile$ on the directory previously opened for read with the ReadDir command, use this command to close the directory. This is good programming practice!
<br />
-
<br />
- See also: ReadDir, NextFile$
- </td>
- </tr>
- </table>
- <h1><a href=../2d_examples/CloseDir.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; ReadDir/NextFile$/CloseDir example
<br />
-
<br />
- ; Define what folder to start with ...
<br />
- folder$="C:"
<br />
-
<br />
- ; Open up the directory, and assign the handle to myDir
<br />
- myDir=ReadDir(folder$)
<br />
-
<br />
- ; Let's loop forever until we run out of files/folders to list!
<br />
- Repeat
<br />
- ; Assign the next entry in the folder to file$
<br />
- file$=NextFile$(myDir)
<br />
-
<br />
- ; If there isn't another one, let's exit this loop
<br />
- If file$="" Then Exit
<br />
-
<br />
- ; Use FileType to determine if it is a folder (value 2) or a file and print results
<br />
- If FileType(folder$+"\"+file$) = 2 Then
<br />
- Print "Folder:" + file$
<br />
- Else
<br />
- Print "File:" + file$
<br />
- End If
<br />
- Forever
<br />
-
<br />
- ; Properly close the open folder
<br />
- CloseDir myDir
<br />
-
<br />
- ; We're done!
<br />
- Print "Done listing files!"
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=CloseDir&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|