【问题标题】:how to move and remove files in WinJS如何在 WinJS 中移动和删除文件
【发布时间】:2013-12-30 18:55:28
【问题描述】:

我在 WinJS 中构建了一个 Metro 应用程序,它在我的硬盘驱动器的临时文件夹中创建了一个图像 (C:\users\temp...)

但我想将我的图片移动到另一个目录,我该怎么做? 提前感谢您的支持

我也想知道如何使用 WinJS 或 Javascript 删除它们

感谢支持


代码

function imageCapture() {
        //Invoke the camera capture UI for snapping a photo
        var captureUI = new _capture.CameraCaptureUI();
        captureUI.photoSettings.format = _capture.CameraCaptureUIPhotoFormat.jpeg;  
        captureUI.captureFileAsync(_capture.CameraCaptureUIMode.photo)
            .then(function (capturedItem) {
                if (capturedItem) {

                    console.log("image path: " + capturedItem.path);

                    //Creates the photo
                    var photoBlobUrl = URL.createObjectURL(capturedItem, { oneTimeOnly: true });
                }
            });
    }

【问题讨论】:

  • 你试过什么?你能显示你卡住的代码吗?没有 Manifest 中请求的特定应用程序权限,您不能随意访问 WinRT 中的文件夹:msdn.microsoft.com/en-us/library/windows/apps/hh967755.aspx
  • 我用图像创建更新了代码,这会将图片存储在 --- C:\Users\myUser\AppData\Local\Packages\9e8dbb07-5b53-4c61-b7c3-3837d07b6210_jxw2p3as84a1r\TempState\ imagenxxxx.jpg,我尚未在清单上启用 Documents/Music/Video 库文件夹,但它仍在工作

标签: javascript file visual-studio-2012 winjs


【解决方案1】:

您可以将图像视为 Storagefile。使用 Storagefile,您可以使用 herehere 移动到另一个文件夹

如果你想删除使用喜欢

storageFile.deleteAsync().done( /* Your success and error handlers */ );

在这里你必须记住 WiredPrairie 评论 没有特定的应用程序权限here,你无法访问文件夹。

相信它会起作用的

【讨论】:

    猜你喜欢
    • 2013-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-30
    • 2016-11-25
    相关资源
    最近更新 更多