Saving files to common grasshopper directory


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.

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

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


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