Skip to content

DirectoryNotFoundException reports wrong path #115483

Closed
@janseris

Description

@janseris

Description

Image

string companyName = "My company d.o.o.";
string productName = "My product name";
string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string applicationLocalAppData = Path.Combine(localAppData, companyName, productName);
Console.WriteLine(localAppData);
Console.WriteLine(applicationLocalAppData);
string fileName = "1.png";
string filePath =  Path.Combine(applicationLocalAppData, fileName);
Console.WriteLine(filePath);
File.WriteAllBytes(filePath, [] /* empty */);

Image

try { File.WriteAllBytes(filePath, [] /* empty */); } catch (Exception ex) { Console.WriteLine(ex.Message); }

Reproduction Steps

Run as .NET 8 console app with top-level statements

Expected behavior

path matches

Actual behavior

dot is missing in company name in reported exception

Regression?

No response

Known Workarounds

No response

Configuration

C:\Users\Jan>dotnet --version
9.0.203

Windows 11

Microsoft Visual Studio Community 2022
Version 17.13.6
VisualStudio.17.Release/17.13.6+35931.197
Microsoft .NET Framework
Version 4.8.09032

Installed Version: Community

C# Tools 4.13.0-3.25167.3+73eff2b5de2ad38ec602c0a9e82f9125fb85992b
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions