本文整理匯總了TypeScript中tns-core-modules/file-system.knownFolders.documents方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript knownFolders.documents方法的具體用法?TypeScript knownFolders.documents怎麽用?TypeScript knownFolders.documents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tns-core-modules/file-system.knownFolders
的用法示例。
在下文中一共展示了knownFolders.documents方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
export var test_getContentAsFile = function (done) {
var result;
// >> http-get-urlfile-content
var filePath = fs.path.join(fs.knownFolders.documents().path, "test.png");
http.getFile("https://httpbin.org/image/png?testQuery=query&anotherParam=param", filePath).then(function (r) {
//// Argument (r) is File!
// >> (hide)
result = r;
try {
TKUnit.assert(result instanceof fs.File, "Result from getFile() should be valid File object!");
done(null);
}
catch (err) {
done(err);
}
// << (hide)
}, function (e) {
//// Argument (e) is Error!
// >> (hide)
done(e);
// << (hide)
});
// << http-get-urlfile-content
};
示例2: testSaveToFile_WithQuality
export function testSaveToFile_WithQuality() {
const img = imageSource.fromFile(imagePath);
const folder = fs.knownFolders.documents();
const path = fs.path.join(folder.path, "test.png");
const saved = img.saveToFile(path, "png", 70);
TKUnit.assert(saved, "Image not saved to file");
TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
示例3:
source.fromAsset(imageAsset).then((source) => {
let folder = fs.knownFolders.documents().path;
let fileName = "test.png"
let path = fs.path.join(folder, fileName);
let saved = source.saveToFile(path, "png");
if(saved){
console.log("saved image")
}
})
示例4:
source.fromAsset(imageAsset).then((imageSource) => {
let folder = fs.knownFolders.documents().path;
let fileName = "test.png";
let path = fs.path.join(folder, fileName);
let saved = imageSource.saveToFile(path, "png");
if (saved) {
console.log("Image saved successfully!");
}
})
示例5: testSaveToFile
export function testSaveToFile() {
// >> imagesource-save-to
const img = imageSource.fromFile(imagePath);
const folder = fs.knownFolders.documents();
const path = fs.path.join(folder.path, "test.png");
const saved = img.saveToFile(path, "png");
// << imagesource-save-to
TKUnit.assert(saved, "Image not saved to file");
TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
示例6: testFromFile
export function testFromFile() {
// >> imagesource-load-local
const folder = fs.knownFolders.documents();
const path = fs.path.join(folder.path, "test.png");
const img = imageSource.fromFile(path);
// << imagesource-load-local
TKUnit.assert(img.height > 0, "image.fromResource failed");
// remove the image from the file system
const file = folder.getFile("test.png");
file.remove();
TKUnit.assert(!fs.File.exists(path), "test.png not removed");
}