Created
June 18, 2026 17:33
-
-
Save rogerpence/07022402568ceff9be95d3f559c61637 to your computer and use it in GitHub Desktop.
AVR code to mimic PowerShell's Get-ChildItem functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Using System | |
| Using System.Collections.Generic | |
| Using System.IO | |
| BegClass Program | |
| BegSr Main Shared(*Yes) Access(*Public) Attributes(System.STAThread()) | |
| DclFld rootPath Type(*String) Inz("C:\Users\thumb\Documents\projects\svelte\examples-dec-2025\project-kyu\src\lib\css\1-base") | |
| DclFld rootDir Type(DirectoryInfo) New(rootPath) | |
| // Verify directory exists | |
| If (*Not rootDir.Exists) | |
| Console.WriteLine("Target directory does not exist.") | |
| Return | |
| EndIf | |
| Try | |
| // 1. Get a list of all DirectoryInfo objects (Recursive) | |
| // GetDirectories returns an array of DirectoryInfo | |
| DclArray allDirectories Type(DirectoryInfo) Rank(1) | |
| allDirectories = rootDir.GetDirectories("*", SearchOption.AllDirectories) | |
| // 2. Get a list of all FileInfo objects with .css extension (Recursive) | |
| DclArray tempFiles Type(FileInfo) Rank(1) | |
| tempFiles = rootDir.GetFiles("*.css", SearchOption.AllDirectories) | |
| // We use a List to filter specifically for ".css" | |
| // (to avoid matching .cssmap or .css-bak) | |
| DclFld cssFiles Type(List(*Of FileInfo)) New() | |
| DclFld file Type(FileInfo) | |
| ForEach file Collection(tempFiles) | |
| If (file.Extension.Equals(".css", StringComparison.OrdinalIgnoreCase)) | |
| cssFiles.Add(file) | |
| EndIf | |
| EndFor | |
| // Output Results | |
| Console.WriteLine("Directories found: " + allDirectories.Length.ToString()) | |
| Console.WriteLine("CSS files found: " + cssFiles.Count.ToString()) | |
| ForEach file Collection(cssFiles) | |
| Console.WriteLine("Found CSS: " + file.FullName) | |
| EndFor | |
| Catch ex1 Type(UnauthorizedAccessException) | |
| Console.WriteLine("Error: You do not have permission to access some subfolders.") | |
| Catch ex2 Type(Exception) | |
| Console.WriteLine("An error occurred: " + ex2.Message) | |
| EndTry | |
| // Keep console window open for debugging | |
| Console.WriteLine("Press any key to exit...") | |
| Console.ReadKey() | |
| EndSr | |
| EndClass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment