Notifications
Clear all

[Closed] test if path is valid?

I’m writing a script that will assign maps read from an IFL to slots in a multisub material. I’d like to be able to test if the paths are valid as I read them from the file. Is this possible?

Also, while I’m at it, is this the best way to read a bunch of bitmap paths from a file to an array?


   iflFile = openFile IFLname
   mapList = #()
  while not eof iflFile do
     (
   	append maplist (readline iflFile)
     )
Cheers,
Cg.
4 Replies

Use the inbuilt Max Function DoesFileExist()

And here’s a function that will check for a valid folder:

fn doesFolderExist f create:false =
 (
 	local val
 	val = if (doesFileExist f) and (getfileattribute f #directory) then true else false
 	if not val and create then
 	(
 		val = makeDir f
 	)
 	val
 )

Set ‘create’ to true to make the folder if it doesn’t exist.

or kick it Dotnet style…


 ((dotnetclass "System.IO.Directory").exists "D:\	emp")
((dotnetclass "System.IO.File").exists "D:\	emp\\Wow.ms")

each return true or false, depending on… well U know…

Exactly what I was lookng for. Thanks guys.

Cg.