Posted By

martinB on 02/06/09


Tagged

file folder exist


Versions (?)

doesFolderExist


 / Published in: Maxscript
 

URL: http://forums.cgsociety.org/showthread.php?f=98&t=634766

Two ways for determining whether a folder exists

  1. fn doesFolderExist f create:false =
  2. -- test whether f exists and is a folder; create it if it doesn't and create==true
  3. (
  4. local val
  5. val = if (doesFileExist f) and (getfileattribute f #directory) then true else false
  6. if not val and create then
  7. (
  8. val = makeDir f
  9. )
  10. val
  11. )
  12.  
  13. -- alternative using dotNet:
  14. ((dotnetclass "System.IO.Directory").exists "D:\\DIRECTORYNAME")
  15. ((dotnetclass "System.IO.File").exists "D:\\SOMEDIR\\SOMEFILE.EXT")

Report this snippet  

You need to login to post a comment.