繁体   English   中英

获取wp8文件夹中的文件数

[英]get Number of file in folder in wp8

我正在尝试获取一个文件夹中的文件数,但以下显示了异常

{System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Data\Programs\{6AF473D1-D227-423A-B6A6-EA76F880B1F8}\Install\Mp3 Files\0\113'

我正在使用下面的文件

public static bool versesExists(byte suraNumber, byte reciterID)
        {
            string folderPath = string.Format("{0}{1}{2}", @"Mp3 Files\", reciterID, @"\" + suraNumber + @"\");
            int totalSuraAyas = 0;
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (storage.DirectoryExists(folderPath))
                {
                    try
                    {

                        DirectoryInfo dir = new System.IO.DirectoryInfo(folderPath);
                        FileInfo[] files = dir.GetFiles("*.mp3");
                        if (files.Length == totalSuraAyas)
                            return true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        return false;
                    }

                }
            }
            return false;
        }

如果看到我正在检查目录是否存在,然后去寻找文件,但是它在“ GetFiles(*。mp3)”中为我提供了例外,我不知道有什么可以解决的?

最可能的原因是,您正在尝试访问隔离存储。

使用“ GetFileNames()”或“ OpenFile()”之类的隔离存储方法来访问隔离存储文件。

文件夹路径中不应有空格。

Mp3文件应该是Mp3Files

string folderPath = string.Format("{0}{1}{2}", @"Mp3Files\", reciterID, @"\" + suraNumber + @"\");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM