TeklaStructuresSettingsGetAdvancedOptionPaths Method |
Gets the value of an advanced option as a list of valid paths.
Strings with path separator ; are split into separate paths and any blank paths (containing only white space) are ignored.
Paths do not need to exist but must use valid characters and format.
Note: All valid paths are returned even when invalid paths are encountered.
Namespace: Tekla.Structures
Assembly: Tekla.Structures (in Tekla.Structures.dll) Version: 2024.0.0+a110b435391768740483e3032720a566518c9a63
Syntax
public static bool GetAdvancedOptionPaths( string advancedOption, out List<string> paths, TeklaStructuresSettingsInvalidPathCallback errorHandler = null )
Parameters
- advancedOption
- Type: SystemString
The advanced option name. - paths
- Type: System.Collections.GenericListString
The paths. - errorHandler (Optional)
- Type: Tekla.StructuresTeklaStructuresSettingsInvalidPathCallback
The optional error handler callback.
Return Value
Type: BooleanTrue if the variable is read successfully and contains no invalid paths; otherwise false.
Examples
The following example gets the first existing instance of a specified file name from the firm,
project or system folders.
using System; using System.Collections.Generic; using System.IO; using Tekla.Structures; public class Example { <summary>An example GetAdvancedOptionPaths error callback which logs any advanced option path error.</summary><param name="advancedOpt">The advanced option being processed when the error occurred.</param><param name="invalidString">The invalid string if identified.</param><param name="exceptionMessage">The exception message if an exception was thrown when converting the string to a path.</param> public static void MyGetAdvancedOptionPathsErrorCallback(string advancedOpt, string invalidString, string exceptionMessage) { Console.WriteLine( string.Format( "The advanced option path string {0} could not be read correctly. Some or all of its content(s) will be ignored.", advancedOption)); if (!string.IsNullOrWhiteSpace(invalidString)) { Console.WriteLine("The invalid string is: " + invalidString); } if (!string.IsNullOrWhiteSpace(exceptionMessage)) { Console.WriteLine("The exception message is: " + exceptionMessage); } } <summary>Tries to get the first existing instance of a specified file name from the firm, project or system folders.</summary><param name="fileName">Name of the file.</param><param name="filePath">The file path of the first file found.</param><returns>True if successful; otherwise false.</returns> public static bool TryGetFileInFirmProjectOrSystemFolders(string fileName, out string filePath) { filePath = null; var advancedOptions = new List<string> { "XS_FIRM", "XS_PROJECT", "XS_SYSTEM" }; foreach (var advancedOption in advancedOptions) { List<string> paths; if (!TeklaStructuresSettings.GetAdvancedOptionPaths( advancedOption, out paths, MyGetAdvancedOptionPathsErrorCallback)) { continue; } foreach (var path in paths) { var fileToFind = Path.Combine(path, fileName); if (File.Exists(fileToFind)) { filePath = fileToFind; return true; } } } return false; } }
See Also