Unable to browse files from unity build using OpenFileDialog()
Hello everybody, I'm fairly new to scripting and I found nothing on forum about my problem. I'm writing code to let the user specify a file from the computer and I used mono's system.windows.form.dll
to call OpenFileDialog()
and retrive the FileName
property. It works fine and without error from the editor, but not in the builded game. From the build when i click the button to retrive the file it shows the file dialog with the correct initial path, but it doesn't show any file or subfolder, I'm only able to navigate in the Enviroment.SpecialFolders
.
Here's the code I used to call OpenFileDialog()
:
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Windows.Forms;
public class MyClass : Monobehaviour
{
OpenFileDialog ofd = new OpenFileDialog();
...
public void SearchFile()
{
string fileName = scenePath;
ofd.InitialDirectory = startDirectory;
ofd.Title = dialogTitle;
ofd.RestoreDirectory = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
fileName = ofd.FileName;
fromSceneDialog = true;
sender = 0;
//Debug.Log(fileName);
SetPath(fileName);
}
}
and here's the result when I call the method SearchFile():
On other forums I read about IO permission, is that the case? Where am I wrong? Thank you (ps. Sorry for my English)
Your answer
Follow this Question
Related Questions
Animation Event problem 0 Answers
Help: Load next level 7 seconds after pick up count reaches 80 3 Answers
Job System usage on Moving Different Transform in Different Speeds 0 Answers
Scene/Level changing problems 1 Answer
Broken Jump Physics 0 Answers