DilanLeeuwendaal

Badges

Name DropperFirst Comment

About

Username
DilanLeeuwendaal
Location
US
Joined
Visits
1
Last Active
Roles
Member
Points
7
Badges
2

DilanLeeuwendaal ✭✭

About

Username
DilanLeeuwendaal
Location
US
Joined
Visits
1
Last Active
Roles
Member
Points
7
Badges
2
  • Save user input to file not working correctly on iOS

    Hello, I am trying to save user selections from different pickers to a text file so that I can retrieve them later.
    However, only the last thing that a user has selected seems to be saved to the file.

    First, I save the user selected row from the Brand picker as below:

    public override void Selected(UIPickerView pickerView, nint row, nint component)
            {
                brandLabel.Text = $"Gekozen apparaat: {brands[pickerView.SelectedRowInComponent(0)]}";
                var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var filename = Path.Combine(documents, "Write.txt");
                File.WriteAllText(filename, brands[pickerView.SelectedRowInComponent(0)]);
            }
    

    Secondly, I save the user selected row from the Device picker as below:

    public override void Selected(UIPickerView pickerView, nint row, nint component)
    {
            deviceLabel.Text = $"Gekozen apparaat: {devices[pickerView.SelectedRowInComponent(0)]}";
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename = Path.Combine(documents, "Write.txt");
            File.WriteAllText(filename, devices[pickerView.SelectedRowInComponent(0)]);
        }
    

    I write both of these selections to "Write.txt".
    Then, I want to show the content of "Write.txt" as below into the console:

        var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var filename = Path.Combine(documents, "Write.txt");
                var text = File.ReadAllText(filename);
    
            Console.WriteLine(text);
    

    But it only shows 1 of the 2 things from only 1 on of the pickers (the second picker).

    What am I doing wrong? Any help is much appreciated!

  • Re: Save user input to file not working correctly on iOS

    Fixed it, used different files (Write.txt and Write2.txt)