C#文件路径
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace XML_Operation { public class URL { public const string ClientHome = "SZ_HOME"; #region Dir //获取环境变量的值 public static readonly string DataFolder = Environment.GetEnvironmentVariable(ClientHome); public static readonly string Config = @"Data\Canaan\Config"; //合并路径目录 public static readonly string DirCalibration = Path.Combine(DataFolder, Config, @"Polisher\Calibration"); public static readonly string DirPLC = Path.Combine(DataFolder, Config, @"Polisher\PLC"); #endregion public static string filePath = Path.Combine(DirCalibration, "Head_LUT.xml"); public static void test() { Console.WriteLine($"{filePath}"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace XML_Operation { class Program { static void Main(string[] args) { URL.test(); Console.ReadKey(); } } }
输出结果:
D:\Sizone\SiZoneProjects\Data\Canaan\Config\Polisher\Calibration\Head_LUT.xml
4556