1
我不使用Android Studio。我在Visual Studio中使用Unity來開發應用程序。我的Environment
課程中沒有看到任何Environment.getExternalStorageDirectory()
。我寫了這段代碼,但它似乎並沒有工作..如何在Unity中使用Visual Studio獲取android文件夾路徑?
public void CreateDirectory()
{
try
{
//Directory.CreateDirectory("/storage/emulated/0/ScratcpPadData");
switch (storeLocation)
{
case Storage.Internal:
Directory.CreateDirectory(@"/storage/sdcard0/" + CustomFolderPath.text + "/");
filePath = "/storage/sdcard0/" + CustomFolderPath.text + "/";
break;
case Storage.External:
Directory.CreateDirectory(@"/storage/sdcard1/" + CustomFolderPath.text + "/");
filePath = "/storage/sdcard1/" + CustomFolderPath.text + "/";
break;
default:
break;
}
File.Create(filePath + FileName.text);
// File.Create()
LogText.text = filePath + FileName.text + " is succesfully created.";
}
catch (IOException ex)
{
LogText.text = "Error: " + ex.Message.ToString();
}
}
誰能告訴我爲什麼?我怎樣才能得到在Visual Studio中的工作與團結的android文件夾路徑(如內部存儲路徑等)?
感謝。我現在就試試吧 –
謝謝它的作品!對不起,遲交回復。 –