An extension to expand environment variables within a string
namespace Common.Environment.EnvironmentVariableExtension { public static class StringEnvironmentVariableExtension { public static string ExpandEnvironmentVariables(this string path) { Debug.Assert(path != null); string result = ""; result = Environment.ExpandEnvironmentVariables(path); return result; } } }and usage
using Common.Environment.EnvironmentVariableExtension; [Test] public void ExpandEnvironmentVariablesUsage() { string path = "%Temp%"; string tempPath = path.ExpandEnvironmentVariables(); }
No comments:
Post a Comment