我正在为android开发unity3d应用程序,我尝试使用File.Move将上传的文件从用户目录移动到android中的Application.persistentDataPath,它在windows中工作正常,但是在我将其导出到android后,它给了我这个错误
system.IO.DirectoryNotFoundException:找不到路径的一部分
这是我正在处理的代码
FileBrowser.ShowLoadDialog( (path) => {
var temp = path.Split('\\');
string filename = "";
foreach (var item in temp)
{
filename = item;
}
// Path.Combine(path);
var dir = Application.persistentDataPath + "/upload";
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir); // create /Upload dir
return;
}else{
Debug.Log("That path exists already.");
}
try{
//Move the selected file
File.Move(path,dir + '/' + filename);
Debug.Log(dir + '/' + filename);
text.GetComponent<Text>().text = dir + '/' + filename;
}catch(Exception e){
text.GetComponent<Text>().text = e.ToString();
}
// FileUtil.MoveFileOrDirectory(path, Application.persistentDataPath + '/' + filename);
},
() => { Debug.Log( "Canceled" ); },
false, null, "Select Folder", "Select" );
}
有人可以帮我解决这个问题吗?
当年话下
莫回无
相关分类