Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Alanimator · Dec 13, 2013 at 04:44 PM · c#assetbundlefiles

How to copy unity.3d file to Application.dataPath directory using WriteAllBytes

Hello i have been able to get a hold of my unity.3d asstet bundle files using File Browser Dialogue in my Unity GUI.

I currently use this code to attempt read all bytes from the selected file and write them to a directory

     string filePath = ("my file path");
             
             string destinationPath = "D:/projects/New folder";
 
 byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
                 System.IO.File.WriteAllBytes(destinationPath,fileBytes);

but i get this error.

UnauthorizedAccessException: Access to the path 'D:/projects/New folder' is denied.

Comment
Add comment · Show 5
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 dvidunis · Dec 13, 2013 at 08:47 PM 0
Share

New to files in unity so I won't post this as an answer, but... are you sure you have permission for this folder? Try running the unity standalone as ad$$anonymous$$.

avatar image Alanimator · Dec 13, 2013 at 09:08 PM 0
Share

I thought of doing that but I have only run it from inside the game engine

avatar image dvidunis · Dec 13, 2013 at 10:26 PM 0
Share

Umm... Try running Unity as ad$$anonymous$$? Also, what OS are you using?

avatar image Alanimator · Dec 14, 2013 at 01:44 PM 0
Share

I'm using Windows but i'm building my game to run on Linux and mac also . to run as ad$$anonymous$$ is a bit too rough around the edges. so i was wondering if there was a way to write to the directory without having to run as ad$$anonymous$$.

avatar image cmpgk1024 · Dec 14, 2013 at 02:37 PM 0
Share

The only way to do it without running as ad$$anonymous$$ is to set the correct permissions for the folder.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by cmpgk1024 · Dec 13, 2013 at 11:01 PM

You most likely don't have permission to write to this folder. You can try either running Unity or your executable as administrator, as mentioned by dvidunis, or change the folders permissions. If you're on Windows, which I am guessing you are because of the file path, you can change the permissions as shown here: http://answers.microsoft.com/en-us/windows/forum/windows_vista-files/how-do-i-change-folder-and-file-permissions/465f2b42-63dd-4486-8dd1-c870290efeed
If you are on OSX or linux, open up your terminal and type

 chmod +rw (path to your folder)
Comment
Add comment · Show 3 · 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
avatar image Alanimator · Dec 14, 2013 at 03:14 PM 0
Share

thanks . i am trying to achieve accessibility to folders without having to manually change permissions.

avatar image cmpgk1024 · Dec 14, 2013 at 04:17 PM 1
Share

This should help you:

 using System.Diagnostics;  
 #if UNITY_STANDALONE_WIN  
     Process.Start("cacls yourfolder /g everyone:f");  
 #endif  
 #if UNITY_EDITOR
     //add the code for the platform you are developing on  
 #endif
 #else
     Process.Start("chmod +rw yourfolder");
 #endif
avatar image Alanimator · Dec 18, 2013 at 06:37 PM 0
Share

tanks a lot for the help cmpgk1024 . since the file i'm trying to import is a unity.ed file i will just try to eve it to resources after importing it as an asset . then i will load from resources

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

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to import the object from server to unity 2 Answers

How to build only specified assets into assetbundle in unity 0 Answers

Add files to folder 1 Answer


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