[Closed] Using .NET System.IO and System Path\Environment Variables
I am curious how to use System Path variables with .NET. Here is an example:
I have a file at:
C: opdirectory
extlevel\lastlevel\myfile.txt
In the System variables I’ve set a path to lastlevel and named it Stuff. So in batch files I can get the file directly with %Stuff%\myfile.txt or jump straight to it in a DOS window by typing
cd %Stuff%
But I cannot figure out how to use that with .NET. Here is an example of my dilemma in the MAXScript listener:
isThere = (dotnetclass "System.IO.File").exists("C: opdirectory
extlevel\lastlevel\myfile.txt")
true
isThere = (dotnetclass "System.IO.File").exists("%Stuff%\myfile.txt")
false
I’ve tried backslashing the % signs, but nothing seems to get me there.
I was trying .NET because I couldn’t get the native MAXScript function doesFileExist() to utilize any system paths.
I am trying to determine if a collection of files exist for an export utility but the problem is that each user has a different path for the required files and I am trying to automate things based off of these system/user variables instead of making users always manually enter paths into configs, etc.
Did you check the Environment class?
http://msdn.microsoft.com/en-us/library/system.environment.aspx
Excellent. Thank you.
I’m pretty fresh on using .NET so haven’t really got a grasp for where to look for anything.