Heya i've been working on this project. Link to Pastebin
And i wonder if its possible to read coordinates instead from the
txtX2 , txtY2 TextBox's
but rather from a text document.
And using those Coordinates in the Text Document instead.
If you dont understand what im saying please reply :P but if you look at the code you will probably understand.
Thanks :)
Assuming you have saved the coordinates in a text file with the following format:
<Coordinate1>,<Coordinate2>
You can do:
String contents = System.IO.File.ReadAllText();
String[] coordinates = contents.Split(',');
Now coordinates[0]
is X
and coordinates[1]
is Y
.
If there are multiple lines in the file and you want to read one line in each timer tick, you can actually do something like this:
// class variable
private StreamReader reader;
// in constructor
reader = System.IO.File.OpenText("PATH");
// in destructor
reader.close();
// in timer
String line;
if ((line = reader.ReadLine()) != null)
{
String[] coordinates = line.split(',');
// now coordinates[0] is X and coordinates[1] is Y
}
Here is a pretty simple example of how to read from a text file:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.