Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectoryNotFoundException: Could not find a part of the path "/storage/emulated/0/Android/data #317

Closed
Amar1312 opened this issue May 3, 2024 · 2 comments

Comments

@Amar1312
Copy link

Amar1312 commented May 3, 2024

Description of the bug

DirectoryNotFoundException: Could not find a part of the path "/storage/emulated/0/Android/data/com.techavtra.GoogleLogin/files/NGallery/02/05/2024_17:59:47.png".
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00000] in <00000000000000000000000000000000>:0
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <00000000000000000000000000000000>:0
at System.IO.File.InternalWriteAllBytes (System.String path, System.Byte[] bytes) [0x00000] in <00000000000000000000000000000000>:0
at NativeGallery.SaveToGallery (System.Byte[] mediaBytes, System.String album, System.String filename, NativeGallery+MediaType mediaType, NativeGallery+MediaSaveCallback callback) [0x00000] in <00000000000000000000000000000000>:0
at Amar.TakePicture+<TakeScreenshotAnd

Reproduction steps

Getting this error with Android 12 devices only

Platform specs

Please provide the following info if this is a Unity 3D repository.

  • Unity version: 2021.3.31
  • Platform: Android
  • Device: Android 12

Additional info
https://learn.microsoft.com/en-us/answers/questions/1194003/storage-emulated-0-batchfiles-system-unauthorizeda?page=1

@yasirkula
Copy link
Owner

It looks like the filename is 02/05/2024_17:59:47.png which is interpreted as 2024_17:59:47.png inside the 05 folder which is inside the 02 folder. The / character is actually forbidden in filepaths for this reason so I'd recommend replacing that character with dot ( . ) or underline ( _ ) before passing it to NativeGallery.

@Amar1312
Copy link
Author

Thanks
It works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants