Hi,
I need to save a txt file from grasshopper.
The issue I have is that I have multiple computers and I want to be sure that file is written and could be opened to the common location.
For examplem, if I just write the file here:C:\Users\ComputerName\AppData\Roaming\Grasshopper\Libraries
It changes from one computer name to another.
DavidLeon
(David Andres Leon)
2
Hi Petras,
You can try %APPDATA%\Grasshopper\Libraries
. In this case &APPDATA%
is the variable name for the application data directory in windows
1 Like
DavidLeon
(David Andres Leon)
3
FYI you can also do this through .NET using System.Environment.GetEnvironmentVariable(“APPDATA”)
. Both of this solutions are windows only.
You can get this path using Grasshopper.Folders.DefaultAssemblyFolder
2 Likes
Thanks Anders and David:)
Another option shown by Dale - the reference to .dll location:
string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
string assemblyPath = System.IO.Path.GetDirectoryName(assemblyLocation);
assemblyPath += @"\Tools.txt";
string[] lines = System.IO.File.ReadAllLines(assemblyPath);
1 Like