如何在Windows Store / WinJS应用程序中处理文件激活
How to handle File Activation in Windows Store / WinJS apps
我正在尝试让我的文本编辑器应用程序处理文件启动。Microsoft在此处提供了如何执行此操作的示例:
http://msdn.microsoft.com/en-us/library/windows/apps/hh452684.aspx
不幸的是,它在接收文件时停止,并且没有提供有关如何实际打开该文件的任何信息。
我可以成功处理激活的事件,最终得到文件的绝对路径。例如
C:'Users'Rory'Documents'test.txt
Metro 应用无权访问绝对路径,除非在某些情况下。
- 如果用户通过文件
- 选取器选择文件
- 如果应用之前访问过该文件,并且路径已存储在 Windows.Storage.AccessCache 中
- 如果应用正在作为启动传递文件。
即使数字 3 在这种情况下适用,我也无法打开该文件。
我已经尝试过Windows.Storage.StorageFile.getFileFromPathAsync(path_to_file)
但是我收到此错误
0x80070005 - JavaScript runtime error: Access is denied.
WinRT information: Cannot access the specified file or folder (6).
The item is not in a location that the application has access to (including
application data folders, folders that are accessible via capabilities
and persisted items in the StorageApplicationPermissions lists). Verify
that the file is not marked with system or hidden file attributes.
我已将应用包清单设置为接受 txt 文件。
StorageFile
或StorageFile
在 WebUIFileActivatedEventArgs
参数中传递给应用。试试这个:
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.file) {
if (args.detail.files.size > 0) {
var storageFile = args.detail.files[0];
Windows.Storage.FileIO.readTextAsync(storageFile).then(function (text) {
// Do something with the content of the file.
});
}
}
// ...
}
相关文章:
- 在MVVM视图模型中处理应用程序范围的元素
- 如何处理IOS网络应用程序中的空锚点
- 如何通过osascript处理同一应用程序的两个实例
- 在Node Webkit应用程序中从DOM单击按钮时运行批处理文件
- 如何在phonegap应用程序中处理Ajax json响应
- 在基于Strophe.js的聊天应用程序中处理状态
- 如何处理数据-Windows 8应用程序
- 简单客户端应用程序中的文件处理
- 如何处理可以'无法在Titanium应用程序上访问主机
- iOS版离线Jquery Mobile应用程序中处理导航的正确方法
- 如何在React应用程序中处理权限检查(Redux中的状态维护)
- Chrome应用程序可以注册协议处理程序吗
- 是什么处理Hello,Lungo应用程序中的导航
- 谷歌应用程序脚本:如何在没有用户交互的情况下调用绑定到处理程序的函数
- 如何处理在多页 HTML/jquery 应用程序中链接到脚本和 css 文件
- 在单页应用程序 (SPA) 中处理身份验证的最佳方法
- Jquery 事件处理程序未在 Rails 应用程序中触发
- 如何处理 Backbone .js应用程序中哈希更改的滚动位置
- 如何在JavaScript上处理金融应用程序的数字,它缺少整数类型
- 是否有一种方法为chrome打包应用程序处理Http BasicAuthentication