1

I have a byte array and need to save it to a file.

I have tried the below code:

File.WriteAllBytes("form.txt", byteArray);

string filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "form.txt");

I have referred https://stackoverflow.com/a/19455387/15265496 for the implementation.

I am looking for the file in Android emulator. Where will the file get saved from first line?

Should I create a form.txt in the application local folder?

Is there any alternative way to do the same?

1

2 Answers 2

0

You can find the appropriate folder using Environment.SpecialFolder.LocalApplicationData

string fileExactLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "form.txt");

You can find more information at https://learn.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/data/files?tabs=windows

Sign up to request clarification or add additional context in comments.

Comments

0

You cannot access the file system of an Android emulator instance via explorer or finder.

As per the Microsoft docs, if you want to store a file in Android, you can always use the application's files folder which is accessible through:

var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

A file saved to that folder will go to

/data/user/0/com.companyname/files

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.