0

This question is an extension of PowerShell - searching for existing files generates empty output.

I'm having trouble capturing long file path names with AlphaFS. I've looked at related AlphaFS questions but I can't see how they address my issue: The code below is intended to capture files in a $source directory into a .csv, including those with paths that are longer than 260 characters. However, the output I get in TestFileLocations.csv consists of 1 line that reads

IsReadOnly|"IsFixedSize"|"IsSynchronized"|"Keys"|"Values"|"SyncRoot"|"Count"

followed by 125060 lines that read

False|"False"|"False"|"System.Collections.Hashtable+KeyCollection"|"System.Collections.Hashtable+ValueCollection"|"System.Object"|"1"

PS Code

[System.Reflection.Assembly]::LoadFrom('C:\AlphaFS\AlphaFS\lib\net35\AlphaFS.dll')
$searchFiles = Import-CSV 'C:\Data\SCRIPTS\PS1\TestFindFile.csv' -Header ("Name")
$source = 'C:\Data\Scripts'
$outputPath = 'c:\data\scripts\ps1\TestFileLocation.csv'

    $searchFiles |  ForEach-Object {
        $files = [Alphaleonis.Win32.Filesystem.Directory]::EnumerateFileSystemEntries($source,'*',[System.IO.SearchOption]::AllDirectories) 
        $files | ForEach-Object { [PSCustomObject] @{FileName = $_} }
    } | export-csv -notypeinformation -delimiter '|' -path $outputPath

My TestFindFile.csv contains only 4 lines pertaining to 3 existing files that should be found by the code. The last file has 262 characters:

Name
123.pdf
321.pdf
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.txt

I'm on Windows 7. Any pointers would be appreciated.

1 Answer 1

1

I wrapped Alphafs into a PS module which you can find on the PowerShell Gallery here.

Since it is a module I cannot post the whole code but can include a link from where you can download it.

PSAlphaFS

Once you have the module you can do something like this :

 Get-LongChildItem -path yourpath | export-csv output.csv -notype
Sign up to request clarification or add additional context in comments.

3 Comments

finally got it to work. I was having compounding issues; seems i had to update to microsoft.com/en-us/download/details.aspx?id=50395 and also connect outside of my company's firewall as it wasn't letting me install PSAlphaFS.
great to hear that!
do you know if PSAlphaFS conflicts with -ErrorAction SiltentlyContinue and/or -exclude ? I have posted here stackoverflow.com/questions/38131238/… (see my second last comment)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.