Skip to content

setAttributes

xiao edited this page Nov 8, 2025 · 1 revision

set attributes of a file or directory.

usage

callback:

fswin.setAttributes(pathToFileOrDir, attributes, [callback]);

async:

var succeeded = await fswin.setAttributesAsync(pathToFileOrDir, attributes);

sync:

var succeeded = fswin.setAttributesSync(pathToFileOrDir, attributes);
  • pathToFileOrDir is a string that specifies the path to a file to directory.
  • attributes is an object that contains new attributes you want to set. for details see example
  • callback is a function that takes only one argument succeeded.
  • succeeded is a bollean value to indicate whether this operation completed successfully.

example

var fswin = require('fswin');
var pathToFileOrDir = 'd:\\test.txt';
var attributes = {
	IS_ARCHIVED: true, //true means yes
	IS_HIDDEN: false, //false means no
	//IS_NOT_CONTENT_INDEXED: true, //remove this attribute if you don't want to change it
	IS_OFFLINE: false,
	IS_READ_ONLY: true,
	IS_SYSTEM: false,
	IS_TEMPORARY: true,
	IS_UNPINNED: true,
	IS_PINNED: false
};

//sync
console.log(fswin.setAttributesSync(pathToFileOrDir, attributes) ? 'done' : 'can not set');

//async
console.log(fswin.setAttributes(pathToFileOrDir, attributes, function (succeeded) {
	console.log(succeeded ? 'done' : 'can not set');
}) ? 'job queued' : 'failed to queue job');

Clone this wiki locally