Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...
How can I write code with c# that download some text with txt format that this text locate right to left in the downloaded file
C#
Response.Clear();
Response.Buffer = false;
Response.AddHeader("content-disposition", "attachment;filename=Export.txt");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-notepad";

using (StringWriter sw = new StringWriter())
{
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    
    sw.Write(ViewState["resultForDownload"].ToString());
    Response.Output.Write(sw.ToString());
    Response.Flush();
    Response.End();
}

This code store some text from left to right in txt file, but I want to save this text from right to left.
Posted
v2

The question, as it is formulated, doesn't really makes sense. The files don't have certain left-to-write or write-to-left direction, they are just sequences of bytes. Moreover, a Unicode text file can have fragments written in left-to-write and write-to-left languages (editing such files in a text editors is a certain challenge; I regularly have to do it, ofter for answering question on this forum :-)). Storage of such data, however (file is just the storage, let's remember it) is not a problem at all.

The code fragment you show suggests that you are dealing with HTTP request and response, which is also, strictly speaking, not a file, and the difference is not just formal (in particular, BOM is insignificant in UTF-8 HTTP response content, but HTTP-EQUIV with encoding is important). Web pages also can freely combine text in left-to-write and write-to-left languages.

Perhaps you need to explain your problem in terms of ultimate goals you have.

—SA
 
Share this answer
 
Text files don't have Right-to-Left or any other form of formatting, there are "raw" files, with new lines being recognised to make life slightly easier.

It is only when you view the content that you can specify how you want the data treated, and that includes the left/right orientation - but it is all on the container you use to view the data, not a part of the data itself.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900