alphaleonis / AlphaFS

AlphaFS is a .NET library providing more complete Win32 file system functionality to the .NET platform than the standard System.IO classes.
http://alphafs.alphaleonis.com/
MIT License
563 stars 99 forks source link

Cannot pipe commands in Powershell #519

Open aborgeld opened 4 years ago

aborgeld commented 4 years ago

Hi everyone,

This wonderful tool solves my long path issues. But i have two questions 1) You have a separate class for Directory and File. Say i have the directory 'Delete' (see code below) but i only want to delete files and folders within the Directory Delete. How can i do this, now it's deleting the whole directory. 2) It seems that adding powershell via a pipe doesn't work. I want to delete files older then 7 days (week), i've tried this: | Where {$_.lastwritetime -lt (Get-Date).AddDays($daysOld)}

Is there a solution to my questions.

Import-Module -Name AlphaFS.dll'
$path = 'D:\Dir\Delete'
     [Alphaleonis.Win32.Filesystem.Directory]::Delete($path,$TRUE)  

#Or 

$path = 'D:\Dir\Delete'
     [Alphaleonis.Win32.Filesystem.File]::Delete($path,$TRUE)  
Yomodo commented 4 years ago

Check out these examples: https://github.com/alphaleonis/AlphaFS/wiki/PowerShell

aborgeld commented 4 years ago

Thank you @Yomodo, i was busy with enumeration. But a foreach on EnumerateFileSystemEntries would be a good place to start.