Issue to write to the file

Peter_1985 2,666 Reputation points
2024-08-21T03:43:25.06+00:00

Hi,

Before this, it was fine to write to the file below. Now it does not.

File1 = "C:/cmp3g/CODECO_ERROR_a/Error0.txt";

Any reason to this?

https://1drv.ms/u/c/17ec75244bac022f/EUXViCYHzylJuDY0vSmAmTwBxMExNH-s6dOppEUVqWUv9Q?e=y0udKd

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,889 questions
{count} votes

Accepted answer
  1. Viorel 117K Reputation points
    2024-08-21T08:56:11.7966667+00:00

    If the folders exists, the next experimental program should work:

    static void Main( string[] args )
    {
       string File1;
       bool allowappend = true;
    
       File1 = "C:/cmp3g/CODECO_ERROR_a/NewFile.txt";
    
       using( StreamWriter sw = new StreamWriter( File1, allowappend, Encoding.Unicode ) )
       {
          sw.WriteLine( "Test" );
          sw.WriteLine( );
       }
    }
    

    Check if NewFile.txt is created by this program.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.