Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a file on the server path "data.txt". It contains a json string. How do I extract that data to a usable string. How do you convert string[] format to string format?
string[] lines = File.ReadAllLines(Server.MapPath("~/data.txt"));
Agent__007 6-Jan-15 23:13pm    
Is there a specific reason not to use File.ReadAllText() method? MSDN Reference:
PIEBALDconsult 6-Jan-15 23:39pm    
Yeah, that's the answer we gave him.
Agent__007 7-Jan-15 1:58am    
Oh, didn't check that. Not sure why he has reposted though, everything was right there! :facepalm:
PIEBALDconsult 6-Jan-15 23:39pm    
We already answered that for you. Please don't respost.

1 solution

Example No 1

// Use string Join to concatenate the string elements.

string result = string.Join("\n", lines);

Example No 2
// Concatenate all the elements into a StringBuilder.

StringBuilder builder = new StringBuilder();
foreach (string value in lines)
string result = builder.ToString();

Please check following link[^]
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