草庐IT

StorageFile

全部标签

c# - 将文件复制到新文件夹中

我在处理文件时遇到问题。我需要复制一个.db文件并将其放入一个新文件夹(称为“目录”,之前使用FolderPicker选择)。我的代码是:(这是用于Windows8.1的商店应用程序)try{StorageFilenewDB=awaitStorageFile.GetFileFromPathAsync(directory);StorageFileoriginalDB=awaitStorageFile.GetFileFromPathAsync(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,"AFB

c# - 如何将 "IStorageItem"的实现传递给 DataPackage.SetStorageItems(items) 并且不在 UWP 上引发 InvalidCastException?

我正在开发一个能够共享其文件的UWP应用程序。我关注了thedocumentationfromMicrosoft该解决方案运行良好。这是我的实现:publicvoidShareLocalFile(LocalFileToSharefile){DataTransferManager.GetForCurrentView().DataRequested+=async(sender,args)=>{vardeferral=args.Request.GetDeferral();try{varstorageFile=awaitStorageFile.GetFileFromPathAsync(file

c# - 如何读取文件 (Metro/WinRT)

我对这个看似简单的任务的明显复杂性感到非常震惊。我知道我必须使用StorageFile类,我找到了这个example,但我只想读取一个我知道路径的文件,并将其数据作为文本读取到字符串中。根据我收集到的信息,使用StorageFile读取文件,我必须经过一堆接口(interface);IAsyncOperation和IAsyncOperationCompletedHandler.一定有更好(更简单)的方法。像这样的东西:using(StorageFilesf=StorageFile.OpenAsync("myFile.txt")){stringline=sf.ReadLine();}显然

c# - 将 StorageFile 上传到 PHP 文件

我一直在尝试将StorageFile(主要是图像文件)上传到PHP文件,以便它可以保存到服务器中。ViewModel.cspublicasyncTaskuploadFile(StorageFilefile){try{using(HttpMultipartFormDataContentform=newHttpMultipartFormDataContent()){using(IInputStreamfileStream=awaitfile.OpenSequentialReadAsync()){HttpStreamContentstreamContent=newHttpStreamCont

c# - 无法将 IStorageItem 转换为 StorageFile

以下代码将无法编译,因为IsOfType不被接受为项目的方法。文档指出:Whenthismethodcompletessuccessfully,itreturnsanIStorageItemthatrepresentsthespecifiedfileorfolder.Ifthespecifiedfileorfolderisnotfound,thismethodreturnsnullinsteadofraisinganexception.Toworkwiththereturneditem,calltheIsOfTypemethodoftheIStorageIteminterfacetod

UWP 从文件 StorageFile 转 SoftwareBitmap 图片方法

本文告诉大家如何在UWP从文件StorageFile转SoftwareBitmap图片的方法使用以下三步即可从文件StorageFile转SoftwareBitmap图片第一步是读取文件,获取可以随机访问的IRandomAccessStream对象。这个对象表示的是一个Stream且此Stream支持随机访问。随机访问是和顺序访问相对,指的是可以从Stream的任意地方开始读写,代码如下using(IRandomAccessStreamstream=awaitinputFile.OpenAsync(FileAccessMode.Read)){}第二步是通过BitmapDecoder的Creat

UWP 从文件 StorageFile 转 SoftwareBitmap 图片方法

本文告诉大家如何在UWP从文件StorageFile转SoftwareBitmap图片的方法使用以下三步即可从文件StorageFile转SoftwareBitmap图片第一步是读取文件,获取可以随机访问的IRandomAccessStream对象。这个对象表示的是一个Stream且此Stream支持随机访问。随机访问是和顺序访问相对,指的是可以从Stream的任意地方开始读写,代码如下using(IRandomAccessStreamstream=awaitinputFile.OpenAsync(FileAccessMode.Read)){}第二步是通过BitmapDecoder的Creat