←Select platform

LibraryPath Property

Summary

Gets or sets a string value representing the path to the native library.

Syntax

C#
Python
public static string LibraryPath { get; set; } 
LibraryPath # get and set (Platform) 

Property Value

A value representing the native library path, as the following:

Platform Native Library Path
Windows LEADTOOLS\\Bin\\CDLL\\x64\\
Linux LEADTOOLS/Bin/Lib/x64/
macOS LEADTOOLS/Bin/Xcode/Frameworks/macOS/

Example

C#
using Leadtools; 
 
private static string GetLibraryPath() 
{ 
   var currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 
   string binFolderName = string.Empty; 
   var kernelName = string.Empty; 
   if (Platform.IsLinux) 
   { 
      binFolderName = Path.Combine("Lib", Platform.Is64Bit ? "x64" : "x86"); 
      kernelName = "libltkrn.so"; 
   } 
   else if (Platform.IsMacOS) 
   { 
      binFolderName = "Xcode/Frameworks/macOS/"; 
      kernelName = "Leadtools.framework"; 
   } 
   else 
   { 
      binFolderName = Path.Combine("CDLL", Platform.Is64Bit ? "x64" : "Win32"); 
      kernelName = Platform.Is64Bit ? "LtKrnx.dll" : "LtKrnu.dll"; 
   } 
 
   const int levels = 10; 
   for (var i = 0; i < levels; i++) 
   { 
      currentDir = Path.Combine(currentDir, ".."); 
 
      var path = Path.GetFullPath(Path.Combine(currentDir, "Bin", binFolderName, kernelName)); 
      if (Platform.IsMacOS && Directory.Exists(path) || File.Exists(path)) 
         return Path.GetDirectoryName(path); 
   } 
 
   throw new DllNotFoundException(kernelName); 
} 
 
public static void InitRuntime(string path) 
{ 
   if (string.IsNullOrEmpty(path)) 
      Platform.LibraryPath = Path.GetFullPath(GetLibraryPath()); 
   else 
      Platform.LibraryPath = path; 
} 

Requirements

Target Platforms

See Also

Platform Class
Platform Members
Leadtools Namespace

Help Version 23.0.2024.7.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.