Exploere/Models/Service.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
namespace Exploere.Models
{
public class Service
{
/// <summary>
/// 获取电脑上所有的磁盘
/// </summary>
/// <returns></returns>
public List<Drives> GetDrives()
{
List<Drives> drivelist = new List<Drives>();
DriveInfo []drives = DriveInfo.GetDrives();
foreach(DriveInfo d in drives)
{
if(d.IsReady)
{
Drives drive = new Drives
{
DType = "本地磁盘",
DriveName=d.Name,
DTotalSize=d.TotalSize/1024/1024/1024+"GB",
DFreeSize=d.TotalFreeSpace/1024/1024/1024+"GB",
};
drivelist.Add(drive);
}
}
return drivelist;
}
/// <summary>
/// 获取指定目录下的目录
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public List<Folder> GetFolders(string path)
{
List<Folder> folderlist = new List<Folder>();
try
{
DirectoryInfo dir = new DirectoryInfo(path);
DirectoryInfo[] folders = dir.GetDirectories();
foreach (DirectoryInfo folder in folders)
{
Folder f = new Folder
{
FolderName = folder.Name,
FolderType = "文件夹",
FolderWriteTime = folder.LastWriteTime.ToString("yyyy-MM-dd HH-mm-ss"),
FolderFullname = folder.FullName,
};
folderlist.Add(f);
}
}
catch(Exception e)
{
后面还有 37 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。