Getting path string from file.
Hello, tell me please where i'm wrong. I'm trying copy string of path from txt file looks like a music playlist to executable script, but if script getting string path (testPath) from inside of txt file then couldn't open file on this path and Debug.Log writes Not Loaded, but if i changed the path string (testPath) in the editor manually in the script then file opens correctly and Debug.Log writes Success.
MyPlayList.pl include this only 2 strings
D:\Tracks\DJ Tanatos - The tunings cars.ogg
D:\Tracks\DJ Tanatos - The tunings cars.ogg
var cLocalPath:String = "file:///";
var testPath:String = "D:/Tracks/DJ Tanatos - The tunings cars.ogg";
var ofd:System.Windows.Forms.OpenFileDialog = System.Windows.Forms.OpenFileDialog();
ofd.Title = "Open audio file";
ofd.Filter = "Play Lists (*.pl) |*.pl";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var sourse:StreamReader = StreamReader(ofd.FileName);
var fileContents:String = sourse.ReadToEnd();
sourse.Close();
var lines:String[] = fileContents.Split("\n"[0]);
testPath = lines[0]; //For test Replaced path string from txt file
Debug.Log(cLocalPath+testPath);
Download();
}
This is Download function:
function Download(){
var www = new WWW(cLocalPath+testPath); //new value of testPath from txt file
while( !www.isDone ) {
return null;
}
if (www.error !=null) {
print ("Not Loaded");
} else {
print ("success");
}
}
Comment
I'm not sure but you could try to replace the backslashes to forward slashes with string.Replace().