I am trying to create a text file and the turnoff the Word Wrap property of the created file. The following is what I'm trying to use to create my text file:
A text file does not have a word wrap property. It is a characteristic of the program that you use to read the file. If you are using Notepad then go to the Format menu to toggle Word Wrap on and off.
However, the strings are wrapping when they are too long to be displayed on one line. Is there any way to turn off the Word Wrap property using C#?
According to your description, I made a demo, but the string did not wrap.
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
{
string path = @"C:\Users\Samwu.WICRESOFT\Desktop\1.txt";
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("1111111111111111111111111111111111111111111");
sw.WriteLine("2222222222222222222222222222222222222222222");
sw.WriteLine("3333333333333333333333333333333333333333333");
sw.WriteLine("1111111111111111111111111111111111111111111");
sw.WriteLine("2222222222222222222222222222222222222222222");
sw.WriteLine("3333333333333333333333333333333333333333333");
}
}
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Response.Write(s);
}
}
}
The result:
Best regards,
Sam
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
42 Points
261 Posts
Create a Text file then Turn Off the Word Wrap Property Using C#
Apr 29, 2020 03:58 AM|ManyTitles|LINK
I am trying to create a text file and the turnoff the Word Wrap property of the created file. The following is what I'm trying to use to create my text file:
However, the strings are wrapping when they are too long to be displayed on one line. Is there any way to turn off the Word Wrap property using C#?
Participant
1620 Points
927 Posts
Re: Create a Text file then Turn Off the Word Wrap Property Using C#
Apr 29, 2020 04:23 AM|PaulTheSmith|LINK
A text file does not have a word wrap property. It is a characteristic of the program that you use to read the file. If you are using Notepad then go to the Format menu to toggle Word Wrap on and off.
Contributor
3370 Points
1409 Posts
Re: Create a Text file then Turn Off the Word Wrap Property Using C#
Apr 29, 2020 05:51 AM|samwu|LINK
Hi ManyTitles,
According to your description, I made a demo, but the string did not wrap.
The result:
Best regards,
Sam