StreamWriter Does Nothing RRS feed

  • Question

  • Has anyone encountered this ridiculousness? Twice now, in two separate projects, StreamWriter just does nothing. No file, no exception, just nothing. I'm assuming there has to be something wrong with my computer. Win 10 Home, VS Community 2019, .Net 4.7.2.

    using System;

    using System.IO;

    namespace Test
        class Program
            static void Main(string[] args)

                    string file = @"file.txt";
                    using (StreamWriter w = new StreamWriter(file, false))
                        w.WriteLine("Just write the file");
                catch (Exception e)

                Console.Write("Press any key to contine...");

    Wednesday, August 7, 2019 1:28 AM


All replies

  • Are you looking in the right place? There are two copies of the executable's created, but the file itself is created under the bin directory.

    The code that you provide produces a file and writes to it normally.

    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Wednesday, August 7, 2019 1:37 AM
  • I've checked it under bin/Debug, tried running it under release, checked bin/Release. Tried running the built executable directly, permissions on the folder are Read/Write/Modify, ran the executable as administrator, run VS as administrator. Get no Exceptions. Setting a breakpoint and stepping through shows each line supposedly execute. I still get no file.
    Wednesday, August 7, 2019 9:12 AM
  • Figured it out. Comodo was blocking.
    • Marked as answer by Clayton.Wolf Wednesday, August 7, 2019 10:07 AM
    Wednesday, August 7, 2019 10:07 AM