markjprice / cs12dotnet8

Repository for the Packt Publishing book titled "C# 12 and .NET 8 - Modern Cross-Platform Development Fundamentals" by Mark J. Price
620 stars 188 forks source link

Page 495, 7. => CurrentDirectory, #11

Closed centpede closed 9 months ago

centpede commented 9 months ago

Dear Mark,

possibly

string path = Combine(CurrentDirectory, "people.xml");

should be changed to

string path = Combine(Directory.GetCurrentDirectory(), "people.xml");

The same on page 499, 3.

Thanks, Robin

markjprice commented 9 months ago

The existing statement works correctly and is shorter so I don't know why you want to change it. Yours works too of course but it's longer.

centpede commented 9 months ago

Strange. I got an "CurrentDirectory ist unknown" error.

markjprice commented 9 months ago

CurrentDirectory is a property of the Environment static class that is imported by the project file:

<ItemGroup>
  <Using Include="System.Console" Static="true" />
  <Using Include="System.IO.Path" Static="true" />
  <Using Include="System.Environment" Static="true" />
</ItemGroup>

image

You must have missed Step 2 on page 493:

image

centpede commented 9 months ago

You are right, I've overseen to include System.Environment from Page 493 /2., my fault, sorry!

markjprice commented 9 months ago

No worries. I suspect that other readers might too, it's easy to overlook because I do not show the actual markup because I was trying to save space in the book (I'm limited to about 750 pages). I've added an improvement item for this: https://github.com/markjprice/cs12dotnet8/blob/main/docs/errata/improvements.md#page-493---serializing-as-xml