StreamWriter.StreamWriter(string) creates folder instead of text file

Will Pittenger 281 Reputation points
2021-04-05T08:16:24.49+00:00

I have an older project that was working. It has a line of code that attempts to create a text file. It looks like this:

new System.IO.StreamWriter(Program.LogXML_FullPath)

Program.LogXML_FullPath returns a string and I've verified the value is as expected. The text file specified doesn't exist. So this constructor should create a text file as I've read the documentation. But it creates a folder with the expected name and appears to try to open that as a text file.

What's going on? As this project was considered stable, it hasn't changed much in ages and targets .NET Framework 4.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,412 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,301 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,125 questions
0 comments No comments
{count} votes

Accepted answer
  1. Will Pittenger 281 Reputation points
    2021-04-05T09:21:26.653+00:00

    Never mind. I stepped through the code once. It didn't create a folder then, but it did the next time that function was called. The new folder had the name of the folder. Sorry.

    0 comments No comments

0 additional answers

Sort by: Most helpful