private string getOutPath() { var sb = new StringBuilder(200); CommunicationHelper.GetPrivateProfileString(XML_CONFIG_SECTION, XML_CONFIG_OUTPATH, "", sb, 200, _configPath); return(sb.ToString().Trim()); }
public void InitializeService(string configPath = null) { _configPath = string.IsNullOrEmpty(configPath) ? DEFAULT_CONFIG_PATH : configPath; if (!File.Exists(_configPath)) { ExceptionEvent?.Invoke(new KRException("InitializeService", "配置文件丢失", "配置文件不存在,请核对")); } var sb = new StringBuilder(200); CommunicationHelper.GetPrivateProfileString(XML_CONFIG_SECTION, XML_CONFIG_INPATH, "", sb, 200, _configPath); InPath = sb.ToString().Trim(); if (!Directory.Exists(InPath)) { ExceptionEvent?.Invoke(new KRException("InitializeService", "客户信息目录异常", "找不到客户信息目录,请核对后重试")); } }
public override void Execute(object parameter) { string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string filePath = Path.Combine(path, "test.udl"); using (var fs = new FileStream(filePath, FileMode.OpenOrCreate)) { } Process process = Process.Start(filePath); process.WaitForExit(); try { var key = new StringBuilder(); CommunicationHelper.GetPrivateProfileString("oledb", null, null, key, 16, filePath); int size = 4 * 255; var sb = new StringBuilder(size); CommunicationHelper.GetPrivateProfileString("oledb", key.ToString(), null, sb, size, filePath); NetworkingViewModel.DatabaseConfigModel.AdvancedConnectionString = key + " = " + sb; if (sb.Length == 0) { MessageBox.Show("UDL 配置不正确!请重新设置!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }