Hi,
Thank you for posting here.
I try to create a console project with the following code, I can run successfully and get sample.text, you could reference code.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
using (StreamWriter writer =
new StreamWriter("sample.txt"))
{
writer.Write("Word ");
writer.WriteLine("word 2");
writer.WriteLine("Line");
writer.WriteLine("Line");
writer.WriteLine("Line");
}
}
}
}
The Write method does not append a newline. The WriteLine methods append a newline "\r\n" at each call.
The program creates the file "sample.txt", which is in the same directory as the application.
>>" No permission set for resource s before accessing it
"
I don't encounter your issue, could you please provide a reproducing demo on one drive to test?
Best Regards,
Hart
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints
to MSDN Support, feel free to contact MSDNFSF@microsoft.com.