1
Answer

Saving text manipulated data

Casper Hansen

Casper Hansen

16y
2k
1
Hello.

I have a small question/problem.

I have this text file:
// Test
0
0    0    0    15    15    7    // 0
end

1
1    1    30    25    25    240    240    -1    5    // 1   
end


I read it into an array in C#, but in my array I read it in as
0    0    0    15    15    7    // 0
1    1    30    25    25    240    240    -1    5    // 1


Since this is a easyer way of manipulating with the data, but now I want to save the data to the text file.
I know the line number of my array, but that does not add up with the orginal file since I stripped som things

So my question is: How do I save the manipulated data so it fits with the orginal data?

My code looks like this:
            string[] SaveMonsterLines = File.ReadAllLines(XMLfileLocation);
            SaveMonsterLines[linenumber] = "1    1    30    25    25    240    240    -1    5    // 1";
            File.WriteAllLines(@"D:/output.txt", SaveMonsterLines);

If you dont understand my question/problem, please speak up :)
Answers (1)