I need to pass the path of the configuration file to the framework method (Gurok SmartInspect). The configuration file is an embedded build resource. I am currently reading a file from an assembly and saving it outside, and then passing the path Name. Is there a better / less complicated way to achieve this without copying the file?
private static void ConfigLogger() { const string embeddedFileName = "xxx.SmartInspect.properties"; const string configFileName = "SmartInspect.properties"; ExtractFileFromAssembly(embeddedFileName, configFileName); SiAuto.Si.LoadConfiguration(configFileName); } private static void ExtractFileFromAssembly(string assemblyFileName, string configFileName) { using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(assemblyFileName) ) { byte[] buffer = new byte[s.Length]; int read = s.Read(buffer, 0, (int)s.Length); using (FileStream fs = new FileStream(configFileName, FileMode.Create)) { fs.Write(buffer, 0, buffer.Length); } } }
source share