【发布时间】:2018-10-30 17:15:51
【问题描述】:
所以我通过 UWP 创建了一个 sample.txt,并在我的 UWP 应用的本地文件夹中复制/粘贴了一个 sample2.pdf 和一个 sample3.mp4。
所以现在我的文件夹中有这 3 个文件。
然后我创建了一个应该保存filename, extension, id and modifiedDate的类
现在我想用示例文件的信息创建这个类的列表。类变量的示例是:filename = sample, extension = .txt, id = sample, modified date = 30.10.2018 09:00
我该怎么做?
到目前为止我的代码:
public sealed partial class MainPage : Page
{
Windows.Storage.StorageFolder storageFolder;
Windows.Storage.StorageFile sampleFile;
List<FileElements> fileInformation = new List<FileElements>();
public MainPage()
{
this.InitializeComponent();
moth();
}
async void moth()
{
storageFolder =
Windows.Storage.ApplicationData.Current.LocalFolder;
sampleFile =
await storageFolder.CreateFileAsync("sample.txt",
Windows.Storage.CreationCollisionOption.ReplaceExisting);
}
public class FileElements
{
public string filename { get; set; }
public string extension { get; set; }
public string id { get; set; }
public string modifiedDate { get; set; }
}
}
我试图用foreach() 方法解决它,但它不起作用
“foreach 语句无法对 StorageFile 类型的变量进行操作,因为 StorageFile 不包含 GetEnumerator 的公共定义”
【问题讨论】: