2017-03-02 15 views
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文件夾路徑(如內部存儲路徑等)?

回答

0

您可以使用的解決方法可以找到here。確保您已在您的構建設置中啓用外部書寫

希望這有助於

+0

感謝。我現在就試試吧 –

+1

謝謝它的作品!對不起,遲交回復。 –

相關問題