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 mmangual_83 · Jan 14, 2014 at 07:08 PM · c#editor-scripting

Copying files from one directory to the other

I have been tinkering with Unity's editor and managed to create a tool that helps me copy files from one directory to the other. It works fine, but for some reason when I want it to copy my files to the desktop it just doesn't let me. It tells me that it fails to copy files.

 using UnityEditor;
 using System.Diagnostics;
 
 public class UnityEditorClass {
 
     [MenuItem("Tools/DLL With Postprocess")]
     public static void BuildGame()
     { 
         // Copy a file from the project folder to the build folder, alongside the built game.
         FileUtil.CopyFileOrDirectory("C:/Projects/SchoolProjects/GSP290/MyFirstGame/vector2.dll", "Desktop/vector2.dlll");
         FileUtil.CopyFileOrDirectory("C:/Projects/SchoolProjects/GSP290/MyFirstGame/matrixHelper.dll", "Desktop/matrixHelper.dll");
     }
 }


Can anyone help me figure out what I am doing wrong and how can I fix this? Thank you in advance!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GameVortex · Jan 14, 2014 at 07:28 PM

Desktop is not a root location. The path to your desktop is something like: C:/Users/UserName/Desktop.

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 mmangual_83 · Jan 14, 2014 at 07:38 PM 0
Share

Ye, I tried that but it doesn't work. Isn't there a way around it?

avatar image GameVortex · Jan 15, 2014 at 08:14 AM 0
Share

You have also included an extra 'l' at the end in the first function. It should not really stop anything, it just renames the file ins$$anonymous$$d. But check all your paths and names for typos. And if it still fails, maybe it does not have access. Try running Unity as ad$$anonymous$$istrator.

avatar image Bunny83 · Jan 15, 2014 at 10:00 AM 1
Share

To get the desktop folder path you can use this. $$anonymous$$eep in $$anonymous$$d to use forward slashes in the path. Also FileUtil is a Unity class, so there might be some additional special formatting of the path since it also allows project paths. Depending on your operating system you (the Unity editor) don't have enough privileges to access the desktop folder.

Try using System.IO classes and see if you get any exception. Usually if an action fails you should get an excpetion telling you what went wrong.

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

21 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 avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Distribute terrain in zones 3 Answers

Working with Unity Editor 1 Answer

Multiple Cars not working 1 Answer

Undo.RecordObjects is not working on 2018.3??? 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