wp 删除独立存储空间文件(多级非空文件夹删除)

void DelFile(string unZipFilePath)//unZipFilePath第一次传递的是根目录名
        {
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (store.DirectoryExists(unZipFilePath))
                {
                    String[] dirNames = store.GetDirectoryNames(string.Concat(unZipFilePath, "\\*"));
                    String[] fileNames = store.GetFileNames(string.Concat(unZipFilePath, "\\*"));
                    if (fileNames.Length > 0)
                    {
                        for (int i = 0; i < fileNames.Length; i++)
                        {
                            store.DeleteFile(string.Concat(unZipFilePath, "\\", fileNames[i]));
                        }
                    }
                    if (dirNames.Length == 0)
                    {
                        store.DeleteDirectory(unZipFilePath);
                        if (unZipFilePath.IndexOf("\\") != -1)
                        {
                            unZipFilePath = unZipFilePath.Substring(0, unZipFilePath.LastIndexOf("\\"));
                            DelFile(unZipFilePath);
                        }
                    }
                    if (dirNames.Length > 0)
                    {
                        for (int i = 0; i < dirNames.Length; i++)
                        {
                            DelFile(string.Concat(unZipFilePath, "\\", dirNames[i]));
                        }
                    }
                }
            }
        }

原文地址:https://www.cnblogs.com/lutter/p/2763081.html