【问题标题】:Saving files in localfolder in Windows 8 app在 Windows 8 应用程序的本地文件夹中保存文件
【发布时间】:2013-10-28 11:12:58
【问题描述】:

我已使用以下代码在我的 Windows 8 应用程序中选择多个文件。

FileOpenPicker fileOpenPicker = new FileOpenPicker();
fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
fileOpenPicker.FileTypeFilter.Add("*");
fileOpenPicker.CommitButtonText = "Select Files";
fileOpenPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
var files = await fileOpenPicker.PickMultipleFilesAsync();

现在我想将选定的文件保存在我的应用程序文件夹中,但现在可以找到这样做的方法。所以任何人都可以帮助我解决这个问题。 谢谢!

【问题讨论】:

    标签: windows-8 windows-runtime microsoft-metro windows-store-apps winrt-xaml


    【解决方案1】:

    如果你想复制本地文件夹中的所有文件,试试这个。

    FileOpenPicker fileOpenPicker = new FileOpenPicker();
    fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
    fileOpenPicker.FileTypeFilter.Add("*");
    fileOpenPicker.CommitButtonText = "Select Files";
    fileOpenPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    var files = await fileOpenPicker.PickMultipleFilesAsync();
    
    foreach (var f in files)
    {
        await f.CopyAsync(ApplicationData.Current.LocalFolder, f.Name, NameCollisionOption.GenerateUniqueName);
    }
    

    【讨论】:

    • 感谢@Xyroid 的帮助
    【解决方案2】:

    用于访问应用程序数据通过

    accessing app data

    但是如果你想将数据存储在安装位置(如果你是通过应用程序文件夹)

    那么这是不可能的,因为安装目录是只读的。你不能添加文件或写入任何文件,但是你可以阅读。 :-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 2014-08-13
      • 1970-01-01
      • 2012-03-28
      • 2014-12-24
      • 1970-01-01
      相关资源
      最近更新 更多