[Closed] File exist issue with maxscript
Hi there!
Im writing a small script to wait for a file to exist and then read .Just it.
But my issue is i have a while loop and it just wait for a file to be exist and my script and 3dsmax get unresponde . . .
Its my script
while true do
(
file_name = openfile “C:/Users/Kasra/Dekstop/t.txt”
if file_name != “undefined” then
(
exit
)
)
file_address = readLine file_name
Can somebody give me a example or code/help/solution?
Thanks a lot!
Thanks a lot.Its kind of complicated for a beginner.
So i should use
setFileSystemWatcher
for scan a directory for a file.
Its totally like dotnet or its different?
If you have time i will appreciate for another simple example or some describe.
any way thanks a lot !You helped too much.
Hope it is clear enough
actionMan.executeAction 0 "40472" -- open MAXScript listener
fn OnFileCreated sender event_args =
(
format ">> %\n" sender
show sender
format "\n>> %\n" event_args
show event_args
format "\nChangeType: '%'\n" (event_args.ChangeType.ToString())
format "FullPath: '%'\n" event_args.FullPath
format "Name: '%'\n" event_args.Name
)
userscripts = getdir #userScripts + "\\"
try( watcher.Dispose() ) catch()
watcher = dotNetObject "system.io.filesystemwatcher" userscripts "*.ini"
dotNet.addEventHandler watcher "Created" OnFileCreated
dotNet.setLifetimeControl watcher #dotnet
clearListener()
watcher.EnableRaisingEvents = true -- start monitoring folder for *.ini file creation
-- this will create a file inside user scripts folder and the watcher will fire 'Created' event which in turn call OnFileCreated function
ini_path = pathConfig.appendPath userscripts "temp_demo.ini"
deleteFile ini_path
setINISetting ini_path "demo" "value" "42"
Thank you so much , This is really helpful for me .
I will let you know about my progress ,however i dont know you loved to or not.