Exemplo n.º 1
0
    private IEnumerator SaveExcel(string titles, string content)
    {
        yield return(FileBrowser.WaitForSaveDialog(FileBrowser.PickMode.Files, false, null, "export.xlsx", "Escolha um destino", "Salvar"));

        if (FileBrowser.Success)
        {
            try
            {
                File.WriteAllText(FileBrowser.Result[0].Substring(0, FileBrowser.Result[0].Length - 4) + "csv", titles + "\n" + content);

                string cmd = Path.GetDirectoryName(Application.dataPath) + "/converter.exe";


                string[] adress = cmd.Split("/"[0]);
                cmd = "";
                for (int i = 0; i < adress.Length; i++)
                {
                    if (adress[i].Contains(" "))
                    {
                        adress[i] = "\"" + adress[i] + "\"";
                    }
                    cmd += adress[i] + "/";
                }
                cmd = cmd.Substring(0, cmd.Length - 1);



                string origin      = FileBrowser.Result[0].Substring(0, FileBrowser.Result[0].Length - 4) + "csv";
                string destination = FileBrowser.Result[0];
                origin      = origin.Replace("\\", "/");
                destination = destination.Replace("\\", "/");

                File.WriteAllText(Path.GetDirectoryName(Application.dataPath) + "/conversionData.csv", origin + "," + destination);

                System.Diagnostics.Process.Start("converter.exe");
            }
            catch (IOException)
            {
                print("Deu erro.");
                Ultilities.PopUp("Arquivo em uso. Feche-o e tente novamente");
            }
        }
    }