I though it was simple. but I didn't manage to make this line of code add "\Game_Progress.xml" to my String
code_file.Insert(code_file.Length, "\\Game_Progress.xml");
Asked
Active
Viewed 48 times
0

R. Oosterholt
- 7,720
- 2
- 53
- 77

jjm
- 13
- 1
-
Possible duplicate of [Why .NET String is immutable?](http://stackoverflow.com/questions/2365272/why-net-string-is-immutable) – ivan_pozdeev Apr 10 '16 at 21:52
2 Answers
1
You can append the string using the +=
operator:
code_file += "\\Game_Progress.xml";
Note: If you want to combine a path, you should consider using the Path Combine method:
System.IO.Path.Combine(code_file, "\\Game_Progress.xml")

Martin Brandl
- 56,134
- 13
- 133
- 172
-1
C# can require an @prior to the string when using backslashes. Try:
code_file.Insert(code_file.Length, @"\\Game_Progress.xml");

Ed Jones
- 104
- 6
-
-
Oh I've never seen that method, always just used @. Well, you learn something new. – Ed Jones Apr 10 '16 at 19:36