I create music player, because I'm learning how to write a Universal App. I'm trying to load a list of all songs in a folder but when I use the GetFiles, Visual Studio shows me the error: "
The name 'Directory' does not exist in the current context"
even though at the beginning of the code I have "using System.IO". What am I doing wrong?
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace project_2
{
public sealed partial class Select : Page
{
private void add_new_song(int song_number)
{...}
private string[] load_songs()
{
string[] paths = Directory.GetFiles(@"C:\");
}
public Select()
{...}
private void GridView_ItemClick(object sender, ItemClickEventArgs e)
{...}
}
}
Directory
is not part of store apps SDK, and even if it would GetFiles
would not exist as there are no synchronous methods in the SDK to access disc resources.
You are likely looking for StoreageFolder.GetFilesAsync or similar API...