I was trying to centralize web.config/app.config using one utility tool. I am able to transform all app.config files in any folder but i am stuck with web.config. Seems webconfigurationmanager will not work outside virtual directory. So i was trying to implement aspnet_regiis encrypt- decryption method in my tool.
private void RunProcess(string processName, string arguments)
{
var newProcess = new ProcessStartInfo(processName);
//Log("User: " + GetSystemName());
if (null != arguments && arguments.Any())
{
newProcess.Arguments = arguments;
newProcess.CreateNoWindow = true;
newProcess.ErrorDialog = true;
newProcess.RedirectStandardError = true;
newProcess.RedirectStandardOutput = true;
newProcess.UseShellExecute = false;
}
using (var proc = new Process())
{
proc.StartInfo = newProcess;
proc.Start();
Console.WriteLine(proc.StandardOutput.ReadToEnd());
proc.WaitForExit();
}
}
private void Encrypt(string path)
{
string framework = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe";
if (8 == IntPtr.Size
|| (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
framework = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe";
RunProcess(framework, " -pef \"connectionStrings\" \"C:\\Users\\xxx\\Desktop\\somefolder\" –prov \"DataProtectionConfigurationProvider\"");
}
My doubt is
" -pef \"connectionStrings\" \"C:\Users\xxx\Desktop\somefolder\" –prov \"DataProtectionConfigurationProvider\""
I am sure i am making some mistake over here the command simply not executing. Its giving me aspnet_regiis help options.