diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index 62e3de2c0..44a58360f 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs @@ -2001,7 +2001,7 @@ public void ToFile(string fileName) #if !NETCORE if (HttpContext.Current != null) #endif - if (fileName.IndexOfAny(new char[] { '\\', ':' }) == -1) + if (!Path.IsPathRooted(fileName)) pathName = Path.Combine(GxContext.StaticPhysicalPath(), fileName); if (ReceiveData != null) diff --git a/dotnet/test/DotNetUnitTest/Domain/GxHttpClientTest.cs b/dotnet/test/DotNetUnitTest/Domain/GxHttpClientTest.cs index 152ebfa6b..cadf70508 100644 --- a/dotnet/test/DotNetUnitTest/Domain/GxHttpClientTest.cs +++ b/dotnet/test/DotNetUnitTest/Domain/GxHttpClientTest.cs @@ -189,6 +189,19 @@ public void HttpClientCookiesTest() } + [Fact] + public void ToRelativeFile() + { + using (GxHttpClient client = new GxHttpClient()) + { + client.Host = "localhost"; + client.BaseURL = "/dummy/lem.txt"; + client.Execute("GET", string.Empty); + client.ToFile("./lem.txt"); + Assert.True(File.Exists(Path.Combine(GxContext.StaticPhysicalPath(), "lem.txt")), $"HttpClient.ToFile failed to create the file at path: {GxContext.StaticPhysicalPath()}"); + } + } + #if !NETCORE [Fact] public void NoStoreHeader()