question

zipswich avatar image
0 Votes"
zipswich asked RobCaplan edited

Why does iOS Files not show an app's file folder?

I followed the instructions to configure Info.plist:
85015-image.png

The window "On My iPhone" of Files is still empty. The paths of files created by the app are like the following:
/var/mobile/Containers/Data/Application/2C5B6D11-41CF-4836-9F2D-CAE73F252CD2/Library/Data/My App/Pictures/Snapshot 2021-04-06 170708.jpg
Could anyone offer a tip on this?

dotnet-xamarin
image.png (63.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
1 Vote"
JarvanZhang-MSFT answered zipswich commented

Hello,​

Welcome to our Microsoft Q&A platform!

Why does iOS Files not show an app's file folder

To make the file be available for browsing in the Files app, please make sure the file is saved in the app's Documents directory. You could refer to the official smaple code and remember to set LSSupportsOpeningDocumentsInPlace to true in the Info.plist file.

It works fine on my side, here is the work screenshot:
85167-image.png

Best Regards,

Jarvan Zhang



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (38.9 KiB)
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sorry for my mistake. To save file to the 'MyDocuments' folder, we also need to set the Supports Document Browser key to true. Please enable the key in the Info.plist file, then test again.

Related code:

button.TouchUpInside += (sender, e) => {
    var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

    var filename = Path.Combine(documents, "MyTestImage.jpg");
    var img = UIImage.FromBundle("MyImage");//the MyImage file is placed in the asset folder
    NSData image = img.AsJPEG();
    NSError err = null;
    image.Save(filename, false, out err);
};


85644-image.png



1 Vote 1 ·
image.png (43.3 KiB)

Thank you for your persistent help.
I copied your code to test it. I added TestImage:
85904-image.png

Unfortunately, both UIImage.FromBundle("TestImage.jpg") and UIImage.FromBundle("TestImage") return null. Could you offer a tip on this?

This is the barebone app for debugging.


0 Votes 0 ·
image.png (87.9 KiB)

Thank you for the help. Could you offer a tip about why File System does not show when I tap "On My iPhone"? It is empty.

The created image file's path is: "/var/mobile/Containers/Data/Application/8674E156-4CD1-4C6F-A7AE-B9C5BAE8C2D0/Documents/Test.jpg"

85393-iphone-files.png


85377-image.png


0 Votes 0 ·
iphone-files.png (91.5 KiB)
image.png (74 B)
image.png (188.7 KiB)
image.png (202.2 KiB)

I just use the code to store the file. Here are the related code and configuration.

button.TouchUpInside += (sender, e) => {
    var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
    var filename = Path.Combine(documents, "MyTestImage.jpg");
    var img = UIImage.FromBundle("MyImage");//the MyImage file is placed in the asset folder
    NSData image = img.AsJPEG();
    NSError err = null;
    image.Save(filename, false, out err);
};

Info.plist

<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UISupportsDocumentBrowser</key>
<true/>


86116-image.png


0 Votes 0 ·
image.png (32.4 KiB)

both UIImage.FromBundle("TestImage.jpg") and UIImage.FromBundle("TestImage") return null. Could you offer a tip on this

If the value is null, try to store a txt file to test the function. Please makr sure the Supports Document Browser key is set to true.

var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var filename = Path.Combine(documents, "Write.txt");
File.WriteAllText(filename, "Write this text into a file!");

1 Vote 1 ·
Show more comments