I created a text file named Write.txt in the Documents folder in a Xamarin.iOS app. After that I was able to read its content to the console.
var documents =
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var filename = Path.Combine(documents, "Write.txt");
File.WriteAllText(filename, "Write this text into a file");
var text = File.ReadAllText(filename);
Console.WriteLine(text); // prints out correctly
The problem is, that I can't found this file on the iPhone simulator's Files app. There is no Documents folder anywhere, and I don't get any results if I search for the filename.
(Yes, I'm new in iOS, so sorry if the question is stupid :) )
You also may just go to the ~/Library/Developer/CoreSimulator/Devices/ folder in Finder ( Shift+Cmd+G ), and then click on the Date modified tab on the top of the folder menu. You'll get the most recently used simulator folder without UDID. After that, I navigate to data/Containers/Data/Application by hand.
# Open application folder in Finder First, copy the path to the app folder from Xcode console. Then open Finder, click on Go -> Go to Folder and paste the application directory path. You will now be able to browse all the files in your application folder.
type: ~/Library/Application Support/iPhone Simulator. The Directories are the iOS version of the different Simulators. The Sub Directories are the Apps install on the simulator.
See Building Great Document-based Apps in iOS 11.
If you want to see it in the files app, you’ll want to set the following value in your Info.plist
:
UISupportsDocumentBrowser
)Or
UIFileSharingEnabled
); andLSSupportsOpeningDocumentsInPlace
)I just run your code and it all works well on my side. The file you written to was successfully opened. I guess you might have some wrong step when opening the folder, let me show you how to do it:
1.I run your code and then print the file path(the filename in your code), on my side it is:
/Users/myName/Library/Developer/CoreSimulator/Devices/0F06FD18-4307-4102-8A30-5EB017A4BD26/data/Containers/Data/Application/20A0294B-36C5-484F-8BD1-B69B977BA378/Documents/Write.txt
2.Go to your mac
--> select Finder
--> Then open the Go menu
--> Click Go to Folder
3.Paste your path to the text box
:
4.Click Go
and you will see the file:
Some folders are hidden in your system so you can't see them when search for the filename. Feel free to ask me if you have any question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With