我正在尝试在我的类库中创建一个 StorageFile 实例...
var localFolder = ApplicationData.Current.LocalFolder;
StorageFile destinationFile = await localFolder.CreateFileAsync(destination, CreationCollisionOption.GenerateUniqueName);
VS11 未构建 say: 'await' 要求类型 'Windows.Foundation.IAsyncOperation' 具有合适的 GetAwaiter 方法。您是否缺少“系统”的使用指令?
显然,我正在使用 .net 4.5 作为目标,并且我正在引用 Windows 程序集... 不知道为什么这段代码在 MetroStyle 中工作但不构建在类库中......我如何在类库中创建 Storagefile 的实例???在这个阶段,文件是否以异步方式创建并不重要......
请告诉我你的想法... 斯泰利奥
最佳答案
对我有用的是“手动”添加 TargetPlatformVersion
<PropertyGroup>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>
并在 Item 组中添加以下内容
<ItemGroup>
<Reference Include="System.Runtime.WindowsRuntime" />
<Reference Include="System.Runtime" />
<Reference Include="Windows" />
</ItemGroup>
然后项目应该可以正常编译。
关于c# - 非 Metro 应用程序中的 StorageFile Async 使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10428446/