Advertisement
MadCortez

Untitled

Jun 27th, 2023
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using MyCloud.Models;
  2.  
  3. namespace MyCloud.Helpers
  4. {
  5.     public static class GetFilesHelper
  6.     {
  7.         public static List<FileData> GetUserFiles(string path)
  8.         {
  9.             var directory = new DirectoryInfo(path);
  10.             List<FileData> returnFiles = new List<FileData>();
  11.             var files = directory.GetFiles();
  12.             foreach(var file in files)
  13.             {
  14.                 FileData toAdd = new FileData();
  15.                 toAdd.FileName = file.Name;
  16.                 toAdd.Path = file.ToString();
  17.                 toAdd.Weight = file.Length;
  18.                 toAdd.CreateDate = file.LastAccessTime;
  19.                 toAdd.AllMemory = file.Length;
  20.                 returnFiles.Add(toAdd);
  21.             }
  22.             return returnFiles;
  23.         }
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement