Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by baopham · Aug 13, 2016 at 08:00 AM · unity 5iosdeletesystem.iowrite data

Delete file in iOS with Application.dataPath get UnauthorizedAccessException: Access to path is denied

Hello everyone, I'm having a little issue with deleting a file on iOS. Basically, I save all my file inside a "AssetBundles" folder then just drag and drop it in the "Data" folder when building the at. I have a file call "buildFlag.dat" to check if the app is just installed in order to clear the cache.

I was successful reading the file and clear the cache, but then when I try to delete the "buildFlag.dat" I got that exception. Does anyone have any idea how to get around this? Thanks in advance, and here is my code snippet:

 public void cleanCacheHelper(){
         string path = Application.dataPath + "/AssetBundles/buildFlag.dat";
         if (File.Exists(path))
         {
             string flag = File.ReadAllText(path);
             if(flag == "Clear")
             {
                 Debug.Log("-->>>> Clearing Cache <<<<--");
                 Caching.CleanCache();
                 #if (UNITY_IOS && !UNITY_EDITOR)
 
                 System.IO.File.Delete(Application.dataPath+"/AssetBundles/buildFlag.dat");
 
                 Debug.Log("Build Flag has been deleted");
                 #endif
             } else
             {
                 Debug.Log("-->>>> Not Clearing Cache <<<<--");
             }
         } else
         {
             Debug.Log("-->>>> Build Flag Does not exist not clearing cache<<<<--");
         }
     }

Here is the log I got: UnauthorizedAccessException: Access to the path "/private/var/mobile/Containers/Bundle/Application/695C517F-AF4C-4490-BE7A-830E32329F91/myapp.app/Data/AssetBundles/buildFlag.dat" is denied.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image davidmcgowan001 · Jun 01, 2020 at 06:50 AM 0
Share

Try to use Long Path Tool, it really can help you with that. It will really help you to solve your problem. ,Hi, for problems concerning path too long issues, I suggest you try the new long path tool. This can help you with all kinds of path too long cases,

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by StuwuStudio · Mar 31, 2017 at 11:01 AM

I know, i'm a bit late but try Application.persistentDataPath instead of Application.dataPath

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Add unityARkit project with IOS project 1 Answer

Admob crashes game on initialize (IOS) 0 Answers

Unity4 deploying Unity5 player? 0 Answers

Pausing on iOS still using CPU 1 Answer

how to embed Unity project inside my iOS project 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges