This is the code I have in a new class:
public static void Save(List<Point> points, int imageWidth, int imageHeight, double originalFactor, double currentFactor)
{
string appDirectory = Path.GetDirectoryName(Application.LocalUserAppDataPath);
string textFile = "LightningsDistance.txt";
string path = "LightningsDistance";
string lightningsDistancePath = Path.Combine(appDirectory,path);
string file = Path.Combine(lightningsDistancePath,textFile);
if (!Directory.Exists(lightningsDistancePath))
{
Directory.CreateDirectory(lightningsDistancePath);
}
if (!File.Exists(file))
{
File.Create(file);
}
}
The format of the text file should be something like:
Image Width: Image Height:
Original Factor: Current Factor:
Points Coordinates:
In the Points Coordinates it should be like this:
Coordinate 1: X = 21, Y = 25
Coordinate 2: X = 210, Y = 344
And so on. The List points is like this for example in index 0 I see: X = 21 Y = 35
In Form1 I have a click button where I call this save method :
private void button2_Click(object sender, EventArgs e)
{
CloudEnteringAlert.Save(picturebox1PointsCoordinates, img.Width, img.Height, factor, currentfactor);
}
I want that when I click the button it will write to the text file and if I clicked once and draw more points and clicked again on the button so it will add (append) the new information to the text file on the same format as above and not to overwrite on the exist file.
Then I have another click button that call a Load method. The Load method is not getting so far anything. Just in the new class:
public static void Load()
{
}
I need that when i click on Load on any time it will read the information from the text file i saved and will assign for now only the Points coordinates back to the List points.