HISE Logo Forum
    • Categories
    • Register
    • Login

    Copy File API

    Scheduled Pinned Locked Moved General Questions
    13 Posts 5 Posters 464 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DanHD
      DanH
      last edited by DanH

      Struggling with this.

      Here's the API

      File.copy(var target)
      

      Here's my code

      LicenseFile.copy(FileSystem.getFolder(FileSystem.AppData));
      

      No errors but not copied file either. Any ideas?

      DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
      https://dhplugins.com/ | https://dcbreaks.com/
      London, UK

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @DanH
        last edited by d.healey

        @DanH Are you sure that LicenseFile exists? I haven't checked but it could be that the target has to be a file not a directory:

        LicenseFile.copy(FileSystem.getFolder(FileSystem.AppData).getChildFile("MyLicense.txt"));

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        DanHD 1 Reply Last reply Reply Quote 0
        • DanHD
          DanH @d.healey
          last edited by

          @d-healey aha that was it, thanks!

          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
          https://dhplugins.com/ | https://dcbreaks.com/
          London, UK

          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @DanH
            last edited by

            @DanH said in Copy File API:

            @d-healey aha that was it, thanks!

            What was?

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            Christoph HartC DanHD 2 Replies Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart @d.healey
              last edited by

              @d-healey If you copy a file somewhere you must ensure that the parent directory exists or the copy action will fail (because it will never implicitly create directories).

              1 Reply Last reply Reply Quote 1
              • DanHD
                DanH @d.healey
                last edited by

                @d-healey it needed to be written / copied to a file, not a directory :)

                DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                https://dhplugins.com/ | https://dcbreaks.com/
                London, UK

                1 Reply Last reply Reply Quote 1
                • Dan KorneffD
                  Dan Korneff
                  last edited by

                  Does copy() only work for specific types of files? I'm trying to copy image files, but it's not working:

                  const var sourceFile = FileSystem.getFolder(FileSystem.Desktop).getChildFile("OldImage.jpg");
                  sourceFile.copy(FileSystem.getFolder(FileSystem.Downloads).getChildFile("NewImage.jpg"));
                  

                  but it works with text:

                  const var sourceFile = FileSystem.getFolder(FileSystem.Desktop).getChildFile("OldText.txt");
                  sourceFile.copy(FileSystem.getFolder(FileSystem.Downloads).getChildFile("NewText.txt"));
                  

                  If so, how can I copy images to new locations?

                  Dan Korneff - Producer / Mixer / Audio Nerd

                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Dan Korneff
                    last edited by

                    @Dan-Korneff I just tested and this works for me

                    const source = FileSystem.getFolder(FileSystem.UserHome).getChildFile("original.png");
                    const target = FileSystem.getFolder(FileSystem.Desktop).getChildFile("test.png");
                    
                    source.copy(target);
                    

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    Dan KorneffD 1 Reply Last reply Reply Quote 0
                    • Dan KorneffD
                      Dan Korneff @d.healey
                      last edited by

                      @d-healey Thanks for testing! It looks like pilot error. It WAS copying the files... with the original attributes. When I sorted my file browser by date, I was expecting to see the new file at the top.

                      Dan Korneff - Producer / Mixer / Audio Nerd

                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @Dan Korneff
                        last edited by

                        @Dan-Korneff said in Copy File API:

                        When I sorted my file browser by date, I was expecting to see the new file at the top.

                        I'm guessing you're on a Mac?

                        Libre Wave - Freedom respecting instruments and effects
                        My Patreon - HISE tutorials
                        YouTube Channel - Public HISE tutorials

                        Dan KorneffD 1 Reply Last reply Reply Quote 0
                        • Dan KorneffD
                          Dan Korneff @d.healey
                          last edited by

                          @d-healey PC

                          Dan Korneff - Producer / Mixer / Audio Nerd

                          d.healeyD 1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @Dan Korneff
                            last edited by

                            @Dan-Korneff Oooh I thought it would give fresh meta data on Windows, interesting!

                            Libre Wave - Freedom respecting instruments and effects
                            My Patreon - HISE tutorials
                            YouTube Channel - Public HISE tutorials

                            LindonL 1 Reply Last reply Reply Quote 0
                            • LindonL
                              Lindon @d.healey
                              last edited by

                              @d-healey said in Copy File API:

                              @Dan-Korneff Oooh I thought it would give fresh meta data on Windows, interesting!

                              create dates would be the same I think - date modified should be different on Windows

                              HISE Development for hire.
                              www.channelrobot.com

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post

                              19

                              Online

                              1.7k

                              Users

                              11.8k

                              Topics

                              102.5k

                              Posts