IEnumerator ShowLoadDialogCoroutine()
    {
        // Show a load file dialog and wait for a response from user
        // Load file/folder: both, Allow multiple selection: true
        // Initial path: default (Documents), Initial filename: empty
        // Title: "Load File", Submit button text: "Load"
        yield return(FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.FilesAndFolders, true, null, null, "Load Files and Folders", "Load"));

        // Dialog is closed
        // Print whether the user has selected some files/folders or cancelled the operation (FileBrowser.Success)
        Debug.Log(FileBrowser.Success);

        if (FileBrowser.Success)
        {
            // Print paths of the selected files (FileBrowser.Result) (null, if FileBrowser.Success is false)
            for (int i = 0; i < FileBrowser.Result.Length; i++)
            {
                Debug.Log(FileBrowser.Result[i]);
            }

            // Read the bytes of the first file via FileBrowserHelpers
            // Contrary to File.ReadAllBytes, this function works on Android 10+, as well
            byte[] bytes = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result[0]);

            // Or, copy the first file to persistentDataPath
            string destinationPath = Path.Combine(Application.persistentDataPath, FileBrowserHelpers.GetFilename(FileBrowser.Result[0]));
            FileBrowserHelpers.CopyFile(FileBrowser.Result[0], destinationPath);
            previewImage.sprite = LoadSprite(destinationPath);
        }
    }
Example #2
0
 public void ExportClicked()
 {
     SimpleFileBrowser.FileBrowser.ShowLoadDialog((paths) =>
     {
         string sourcePath           = Path.Combine(Application.persistentDataPath, "StorageDatabase.FILE");
         string destinationDirectory = FileBrowserHelpers.GetDirectoryName(FileBrowser.Result[FileBrowser.Result.Length - 1]);
         string destinationPath      = Path.Combine(destinationDirectory, "StorageDatabase.FILE");
         FileBrowserHelpers.CopyFile(sourcePath, destinationPath);
     }, null, SimpleFileBrowser.FileBrowser.PickMode.Folders);
 }
Example #3
0
    public void ImportClicked()
    {
        SimpleFileBrowser.FileBrowser.SetFilters(false, new SimpleFileBrowser.FileBrowser.Filter(
                                                     "Databases", ".DB", ".DBS", ".SQL", ".SQLITE3", ".SQLITE3", ".FILE"));

        SimpleFileBrowser.FileBrowser.ShowLoadDialog((paths) =>
        {
            string destinationPath = Path.Combine(Application.persistentDataPath, FileBrowserHelpers.GetFilename(FileBrowser.Result[0]));
            FileBrowserHelpers.CopyFile(FileBrowser.Result[0], destinationPath);
        }, null, SimpleFileBrowser.FileBrowser.PickMode.Files);
    }
Example #4
0
        IEnumerator ShowLoadDialogCoroutine()
        {
            // Show a load file dialog and wait for a response from user
            // Load file/folder: both, Allow multiple selection: true
            // Initial path: default (Documents), Initial filename: empty
            // Title: "Load File", Submit button text: "Load"
            yield return(FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.FilesAndFolders, true, null, null, "Load Files and Folders", "Load"));

            if (FileBrowser.Success)
            {
                // Print paths of the selected files (FileBrowser.Result) (null, if FileBrowser.Success is false)
                for (int i = 0; i < FileBrowser.Result.Length; i++)
                {
                    _imageSavePath = _songSavePath = FileBrowser.Result[0];
                }

                // Read the bytes of the first file via FileBrowserHelpers
                // Contrary to File.ReadAllBytes, this function works on Android 10+, as well
                byte[] bytes = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result[0]);

                // Or, copy the first file to persistentDataPath
                string destinationPath = Path.Combine(Application.persistentDataPath, FileBrowserHelpers.GetFilename(FileBrowser.Result[0]));
                FileBrowserHelpers.CopyFile(FileBrowser.Result[0], destinationPath);

                if (_imageSavePath.ToLower().EndsWith(".png") && _imageSavePath.Length > 1 || _imageSavePath.ToLower().EndsWith(".jpg") && _imageSavePath.Length > 1)
                {
                    string[] world = (Application.platform == RuntimePlatform.Android) ? _imageSavePath.Split('/'): _imageSavePath.Split('\\');
                    _imageName = world[world.Length - 1];
                    GetImage();
                }
                if (_songSavePath.ToLower().EndsWith(".mp3") && _songSavePath.Length > 1)
                {
                    string[] world = (Application.platform == RuntimePlatform.Android) ? _imageSavePath.Split('/') : _imageSavePath.Split('\\');
                    _songName = world[world.Length - 1];
                    GetSong();
                }
            }
        }