Snippets Collections
$filename = 'D:\PS\CSV\PowerShell-EventLogs.csv'    

# Get file size in bytes
(Get-Item -Path $filename).Length

# get file size in KB in PowerShell
(Get-Item -Path $filename).Length/1KB

# get file size in MB in PowerShell   
(Get-Item -Path $filename).Length/1MB

# get file size in GB in PowerShell
(Get-Item -Path $filename).Length/1GB  
public static void deleteDirectory(File path) 
{
    if (path == null)
        return;
    if (path.exists())
    {
        for(File f : path.listFiles())
        {
            if(f.isDirectory()) 
            {
                deleteDirectory(f);
                f.delete();
            }
            else
            {
                f.delete();
            }
        }
        path.delete();
    }
}
const http = require('http');
 
let requestListener = (request, response) => {
  response.writeHead(200, {'Content-Type': 'text/plain' });
  response.write('Hello World!\n');
  response.end();
};
 
const server = http.createServer(requestListener);
 
server.listen(3000);
const fs = require('fs')
 
const fileStream = fs.createWriteStream('output.txt');
 
fileStream.write('This is the first line!'); 
fileStream.write('This is the second line!');
fileStream.end();
const readline = require('readline');
const fs = require('fs');
 
const myInterface = readline.createInterface({
  input: fs.createReadStream('text.txt')
});
 
myInterface.on('line', (fileLine) => {
  console.log(`The line read: ${fileLine}`);
});
const fs = require('fs');
 
let readDataCallback = (err, data) => {
  if (err) {
    console.log(`Something went wrong: ${err}`);
  } else {
    console.log(`Provided file contained: ${data}`);
  }
};
 
fs.readFile('./file.txt', 'utf-8', readDataCallback);
# By default, each destination (name of new link) should not already exist

ln -s /home/user/project /var/www/html

# The link will be created inside /var/www/html having the name of the target i.e. project.
# If you want to have a symlink /var/www/html pointing to /home/user/project then you should not have the directory html present beforehand. So, you should only have /var/www and then running the following will create the desired symlink (don't do this unless you are sure)
star

Mon Oct 31 2022 02:56:23 GMT+0000 (Coordinated Universal Time) https://shellgeek.com/powershell-get-file-size/

#powershell #file #filesystem #measure
star

Tue Feb 22 2022 22:30:06 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/779519/delete-directories-recursively-in-java

#java #delete #filesystem
star

Tue Aug 31 2021 02:07:50 GMT+0000 (Coordinated Universal Time)

#node #filesystem
star

Tue Aug 31 2021 01:55:22 GMT+0000 (Coordinated Universal Time)

#node #filesystem
star

Fri Jun 18 2021 08:58:12 GMT+0000 (Coordinated Universal Time) https://askubuntu.com/a/600732

#symlink #linux #filesystem

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension