Example #1
0
        public NativeFileSystem()
        {
            int storagePathLength;

            RootPath = FindRootPath(out storagePathLength);

            if (RootPath == null)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Content directory was not found!");
                sb.AppendLine();
                sb.AppendLine("Searched mount points:");

                List <StorageInfo> storages = GetStorageList();
                for (int i = storages.Count - 1; i >= 0; i--)
                {
                    sb.Append(" - ");
                    sb.Append(storages[i].Path);
                    sb.Append(" (");

                    if (storages[i].IsReadOnly && storages[i].IsRemovable)
                    {
                        sb.Append("Read-only removable");
                    }
                    else if (storages[i].IsReadOnly)
                    {
                        sb.Append("Read-only fixed");
                    }
                    else if (storages[i].IsRemovable)
                    {
                        sb.Append("Removable");
                    }
                    else
                    {
                        sb.Append("Fixed");
                    }

                    sb.AppendLine(")");
                }

                CrashHandlerActivity.ShowErrorDialog(new DirectoryNotFoundException(sb.ToString()));
            }

            App.Log("Android Root Path: " + RootPath);
        }
Example #2
0
        public NativeFileSystem()
        {
            string packageName = Application.Context.PackageName + "/";

            List <StorageInfo> storages = GetStorageList();

            for (int i = storages.Count - 1; i >= 0; i--)
            {
                string path = Path.Combine(storages[i].Path, "Android", "Data", packageName);
                if (Directory.Exists(path))
                {
                    RootPath = path;
                    break;
                }

                path = Path.Combine(storages[i].Path, packageName);
                if (Directory.Exists(path))
                {
                    RootPath = path;
                    break;
                }

                // ToDo: Remove this in future versions
                path = Path.Combine(storages[i].Path, "Download", packageName);
                if (Directory.Exists(path))
                {
                    RootPath = path;
                    break;
                }
            }

            if (RootPath == null)
            {
                //throw new DirectoryNotFoundException("Content directory was not found");

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Content directory was not found!");
                sb.AppendLine();
                sb.AppendLine("Searched mount points:");

                for (int i = storages.Count - 1; i >= 0; i--)
                {
                    sb.Append(" - ");
                    sb.Append(storages[i].Path);
                    sb.Append(" (");

                    if (storages[i].IsReadOnly && storages[i].IsRemovable)
                    {
                        sb.Append("Read-only removable");
                    }
                    else if (storages[i].IsReadOnly)
                    {
                        sb.Append("Read-only fixed");
                    }
                    else if (storages[i].IsRemovable)
                    {
                        sb.Append("Removable");
                    }
                    else
                    {
                        sb.Append("Fixed");
                    }

                    sb.AppendLine(")");
                }

                CrashHandlerActivity.ShowErrorDialog(new DirectoryNotFoundException(sb.ToString()));
            }

            Console.WriteLine("Android Root Path: " + RootPath);
        }