CloseDir.htm 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>CloseDir filehandle</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. filehandle = valid filehandle assigned from the ReadDir command
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. 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 />
  21. <br />
  22. See also: ReadDir, NextFile$
  23. </td>
  24. </tr>
  25. </table>
  26. <h1><a href=../2d_examples/CloseDir.bb>Example</a></h1>
  27. <table>
  28. <tr>
  29. <td>
  30. ; ReadDir/NextFile$/CloseDir example <br />
  31. <br />
  32. ; Define what folder to start with ... <br />
  33. folder$="C:" <br />
  34. <br />
  35. ; Open up the directory, and assign the handle to myDir <br />
  36. myDir=ReadDir(folder$) <br />
  37. <br />
  38. ; Let's loop forever until we run out of files/folders to list! <br />
  39. Repeat <br />
  40. ; Assign the next entry in the folder to file$ <br />
  41. file$=NextFile$(myDir) <br />
  42. <br />
  43. ; If there isn't another one, let's exit this loop <br />
  44. If file$="" Then Exit <br />
  45. <br />
  46. ; Use FileType to determine if it is a folder (value 2) or a file and print results <br />
  47. If FileType(folder$+"\"+file$) = 2 Then <br />
  48. Print "Folder:" + file$ <br />
  49. Else <br />
  50. Print "File:" + file$ <br />
  51. End If <br />
  52. Forever <br />
  53. <br />
  54. ; Properly close the open folder <br />
  55. CloseDir myDir <br />
  56. <br />
  57. ; We're done! <br />
  58. Print "Done listing files!"
  59. </td>
  60. </tr>
  61. </table>
  62. <br>
  63. <a target=_top href=../index.htm>Index</a><br>
  64. <br>
  65. 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>
  66. </html>