我在资产文件夹中放了一些项目。如下:
|资产
| _ONE
| _CAT.JPEG
我想确定“ONE”是否是目录,“CAT.JPEG”是文件。
我尝试用下面的东西:
AssetManager _assetManager = Assets;
string[] _files = null;
try
{
_files = _assetManager.List("");
}
catch(IOException e)
{
Log.Error("Get All Child", "Failed to get asset file list.", e);
}
string _rootAssetFolder = "file:///android_asset/";
foreach(string _filename in _files)
{
string _sourcePathFull = _rootAssetFolder+ _filename;
Java.IO.File _target = new Java.IO.File(_sourcePathFull);
if(_target.IsDirectory)
{
Console.WriteLine("IS DIRECTORY");
}
else if(_target.IsFile)
{
Console.WriteLine("IS FILE");
}
else
{
Console.WriteLine("UNRECOGNIZE");
}
}
但我总是得到UNRECOGNIZED
这有助于https://www.tutorialspoint.com/java/io/file_isfile.htm你在_sourcePathFull中设置了什么?