- Home /
Question by
Kirbsssys · Mar 30 at 12:27 AM ·
save dataapplicationtext file
How do I save a .txt file in a certain folder
I want to save the .txt file in a folder outside of the game files
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System;
using UnityEngine.UI;
public class BackUp : MonoBehaviour
{
public float bTatos;
public float b;
public Controller con;
public bool can = false;
private void Update()
{
if(can == true)
{
con = null;
}
else
{
con = GetComponent<Controller>();
}
}
public void Load()
{
can = true;
}
public void BackUps()
{
if (can == false)
{
bTatos = con.tatos;
}
string path = Application.persistentDataPath + "/Log.txt";
this is the part where it saves it to a certain folder, and I want to know how to change it to /storage/emulated/0/Download/Log.txt, or something like that.
if (can == false)
{
string content = bTatos + "\n";
if (!File.Exists(path))
{
File.WriteAllText(path, content);
}
File.WriteAllText(path, content);
}
string text = File.ReadAllText(path);
b = float.Parse(text);
if (can == true)
{
con.tatos = b;
can = false;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Where to save player progress for playstore app? 1 Answer
Saving or Reading text file works on Mac but not on iOS 1 Answer
What does "SerializationException: Unexpected binary element: 116" mean? 1 Answer
Variable names are still visible when saving with binaryFormatter 1 Answer
Multiplayer , account to log in with and saved inventory after a game 0 Answers