码迷,mamicode.com
首页 > 移动开发 > 详细

c# 枚举安卓系统中所有目录及文件名

时间:2019-01-21 17:12:44      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:bsp   run   ext   erp   sys   throw   prot   dia   new   

using Android.App;
using Android.Widget;
using Android.OS;
using System.Runtime.InteropServices;

namespace App2
{
    [Activity(Label = "App2", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        [DllImport("TestDynamicSharedLib.so")]
        public extern static int getClickCount();

        protected override void OnCreate(Bundle bundle)
        {
            var c = getClickCount();

            //string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.System);

            printAllSubFiles("/");

            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            // SetContentView (Resource.Layout.Main);
        }

        void printAllSubFiles(string path)
        {
            System.Diagnostics.Debug.Print("dir:" + path);

            var dir = new System.IO.DirectoryInfo(path);

            try
            {
                foreach (var f in dir.GetFiles())
                {
                    System.Diagnostics.Debug.Print("file:" + f.FullName);
                }
            }
            catch 
            {
                //throw;
            }

            try
            {
                foreach (var d in dir.GetDirectories())
                {
                    printAllSubFiles(d.FullName);
                }
            }
            catch (System.Exception)
            {
                //throw;
            }
            
        }
    }
}

 

c# 枚举安卓系统中所有目录及文件名

标签:bsp   run   ext   erp   sys   throw   prot   dia   new   

原文地址:https://www.cnblogs.com/nanfei/p/10299458.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!