i have an APP who save test file, thi is the code:
string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData ), "Test.txt");
//Pass the filepath and filename to the StreamWriter Constructor
StreamWriter sw = new StreamWriter(fileName);
//Write a line of text
sw.WriteLine("Hello World!!");
//Write a second line of text
sw.WriteLine("From the StreamWriter class");
//Close the file
sw.Close();
the file is saved on this path:
/data/user/0/com.companyname.inventario_app/files/.local/share/Test.txt
The problem IS:
Why I can't find the file on mobile device using computer, (the computer is connected by USB)?
There is a way for save the text file on a accessible folder of the DEVICE?
Or there is a way to get the file from PC??
THANKS a lot
Riccardo DariaPosted Feb 1, 2024, 3:12 PM
Thanks, but i have this errore:
Android does not contain a definition for 'OS'
on line:
string fileName = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "Test.txt");
WHY???
Jayraj ChhayaPosted Feb 1, 2024, 9:41 AM
You're experiencing is because the file is saved in the local application data folder of the device. This folder is not directly accessible from a connected computer.
To solve this problem, you have a couple of options:
Make sure you have ADB installed on your computer and that your device is connected via USB with USB debugging enabled.