xamarin.android 获取手机存储路径或文件
app需要播放安卓平板中的视频文件。在mainactivity中获取指定文件夹中的所有文件地址。try{string filepath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/hcvideo";...
·
app需要播放安卓平板中的视频文件。
在mainactivity中获取指定文件夹中的所有文件地址。
try
{
string filepath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/hcvideo";
string[] items = System.IO.Directory.GetFiles(filepath);
HcCustomApp.MainPage.videofiles = items;
}
catch (System.Exception excp)
{
XamarinApp.StandardLib.Config.WriteLog($"未发现视频路径或文件: {excp.Message}");
}
Android.OS.Environment.ExternalStorageDirectory.AbsolutePath 获取出来的结果是 storage/emulated/0,
用手机测试的时候,将视频拷贝到内部存储/storage/emulated/0/hcvideo中,一直提示找不到路径。
后来,比对文件才发现,原来Android.OS.Environment.ExternalStorageDirectory.AbsolutePath 代表的是根目录,也就是到内部存储为止。所以,要将视频拷贝到 内部存储/hcvideo中,就OK了。
更多推荐
已为社区贡献2条内容
所有评论(0)