Windows Phone アプリケーションに問題があると思います。私のアプリケーションには、特定のフォルダーにあるテクスチャのコレクションを返す静的メソッドがあります。WP 8 エミュレーターでアプリケーションを起動すると、非常にうまく機能しますが、WP 7 エミュレーターで起動すると、「ディレクトリが存在しません」というメッセージで例外が発生します。しかし、実際にはこのディレクトリは存在します。なぜこれが起こるのか誰か教えてもらえますか?
ここに私のコードを添付しました:
namespace Hornbook_v2
{
public static class ContentLoader
{
public static Dictionary<String, T> LoadTextures<T>(this ContentManager contentManager, string contentFolder)
{
//Load directory info, abort if none
DirectoryInfo dir = new DirectoryInfo(contentManager.RootDirectory + "\\" + contentFolder);
// The exception is happends HERE!!!
if (!dir.Exists)
throw new DirectoryNotFoundException();
//Init the resulting list
Dictionary<String, T> result = new Dictionary<String, T>();
//Load all files that matches the file filter
FileInfo[] files = dir.GetFiles("*.*");
foreach (FileInfo file in files)
{
string key = Path.GetFileNameWithoutExtension(file.Name);
//result[key] = contentManager.Load<T>(contentManager.RootDirectory + "/" + contentFolder + "/" + key);
result[key] = contentManager.Load<T>(contentFolder + "/" + key);
}
//Return the result
return result;
}
}
}