view=netcore-3.1 1.2.2 DirectoryInfo 之前的篇幅我们介绍了Directory的工具类所支持的方法,接下来我们看一下 DirectoryInfo有哪些属性和方法吧。...public DirectoryInfo (string path); 初始化的方式很简单,直接传递一个目录的路径字符串,就可以获取一个目录信息类了。...接下来看看,DirectoryInfo支持的属性: public override bool Exists { get; }// 目录是否存在 public override string Name {...System.IO.DirectoryInfo Root { get; }//获取目录的根目录 我们路过了DirectoryInfo的属性,看到了它一部分特点,那么我们该怎么使用呢?...); public System.Collections.Generic.IEnumerable EnumerateDirectories (string
它的属性: //获取文件的特性信息 FileAttributes Attributes; DateTime CreationTime; DateTime LastAccessTime; DateTime...public FileInfo(string fileName); 它的属性: //表明文件是否存在 override bool Exists; //获取文件名(包含后缀名)。...DirectoryInfo类的构造函数: //在指定路径上初始化DirectoryInfo新实例 public DirectoryInfo(string path); 它的属性: override bool...> EnumerateDirectories(string searchPattern); IEnumerable EnumerateDirectories(string...IEnumerable EnumerateFiles(); IEnumerable EnumerateFiles(string searchPattern); IEnumerable
在MVVMLight中,依赖属性和命令的绑定一般都是放在Xaml中,并且大部分情况下不需要给控件定义Name属性。...在WhenActivated API的函数回调中进行绑定属性和Command,可以同步跟踪View和对应绑定属性的生命周期,避免发生内存泄露。...定义属性和命令 在MVVMLight中定义一个带通知的属性和Commond: private string content ; public string Content...private async Task> LoadFolderInfoWithSelectedDiskChanged(string diskName)...{ List folderModels = new List(); var files
下图为Prism体系中的关系结构图。...首先我们将项目中的module编译生成到项目运行目录下的Apps文件夹下。 这时需要在类库右键->点击属性。 将DLL编译生成时拷贝到,指定目录下(详情见源码)。...path) { DirectoryInfo directory = new DirectoryInfo(path); ResolveEventHandler...name = type.Name; List list = new List(); bool flag = false;... list = new List(); IEnumerable collection = from Assembly assembly
path, IEnumerable contents) public static void AppendAllLines(string path, IEnumerable<string...) public static IEnumerable ReadLines(string path, Encoding encoding) //根据路径返回文件的所有文本字符 public...上一篇文章里面介绍了DirectoryInfo类的用法,Directory类里面的很多功能和DirectoryInfo提供的功能类似,并提供了更多的方法,通过查看.Net Framework源码,DirectoryInfo...类里面有调用Directory的方法,Directory里面也引用到DirectoryInfo类。...静态类Path: 它的属性: readonly static char DirectorySeparatorChar; readonly static char AltDirectorySeparatorChar
> OverDirectories(IEnumerable directories) { var tasks = directories.Select...,List> OverDirectories(DirectoryInfo rootDirectory) { Console.WriteLine($"正在遍历目录:{rootDirectory.FullName...}"); var dict = new Dictionary>(); IEnumerable files = new List...,所以需要重新修改遍历文件路径的方法,只保留路径: public static List OverDirectories(DirectoryInfo rootDirectory) {... directories){ var tasks =new List>>( directories.Select(dir =>
Enumerable.ContainsQueryable.Contains 05 投影运算 投影是指将对象转换为一种新形式的操作,该形式通常只包含那些将随后使用的属性。.../ *********** Select *********** 16 IEnumerable> query1 = bouquets.Select...Enumerable.OfTypeQueryable.OfType ToArray 将集合转换为数组。 此方法强制执行查询。 不适用。...此方法强制执行查询。 不适用。 Enumerable.ToDictionary ToList 将集合转换为 List。 此方法强制执行查询。 不适用。...此方法强制执行查询。 不适用。 Enumerable.ToLookup 查询表达式语法示例 下面的代码示例使用显式类型化的范围变量将类型转换为子类型,然后才访问仅在此子类型上可用的成员。
顾名思义,具有如下定义的NotFoundFileInfo类型表示一个“不存在”的文件。NotFoundFileInfo对象的Exists属性总是返回False,而其他的属性则变得没有任何意义。...既然PhysicalFileInfo是对一个FileInfo对象的封装,那么我们应该想得到PhysicalDirectoryInfo对象封装的就是表示目录的DirectoryInfo对象。...如下面的代码片段所示,我们需要在创建一个PhysicalDirectoryInfo对象时提供这个DirectoryInfo对象,PhysicalDirectoryInfo实现的所有属性的返回值都来源于这个...DirectoryInfo对象。...PhysicalDirectoryContents的Exists属性取决于指定的目录是否存在。
再看一下属性: public string Name { get; }// 获取驱动器的名称,如 C:\。...;//泛型集合的支持 修改方法如下: public static List GetDrivers() { var drives = DriveInfo.GetDrives...,之后对遍历结果归类: 修改OverrDirectories方法: public static Dictionary> OverDirectories(DirectoryInfo...>> OverDirectories(DirectoryInfo rootDirectory) { var dict = new Dictionary>...(); IEnumerable files = new List(); try { files = rootDirectory.EnumerateFiles
;ReadLines对于大文件的操作更擅长一些,但是可能会更久的持有文件 b.写入文件 public static void AppendAllLines (string path, System.Collections.Generic.IEnumerable...先来看看文件的基本属性 public override bool Exists { get; } 文件是否存在,等效于File.Existss(string path)。...最新版C#的API,取消了通过FileInfo获取文件的格式名的属性以及其他的很多属性,只保留了文中提到的几个属性。...1.2 Directory和DirectoryInfo 与之前的类似,Directory也是个工具类,DirectoryInfo则代表目录实例。 1.2.1 Directory 先来个简单的: a....创建目录: public static System.IO.DirectoryInfo CreateDirectory (string path); 如果目录已存在,则跳过创建,直接返回指定路径的DirectoryInfo
如果不是文本信息,要转换为文本信息,比如要检索Excel文件,就要用NPOI把Excel读取成字符串,然后把字符串扔给Lucene.Net。...Document类代表要索引的文档(文章),最重要的方法Add(Field field),向文档中添加字段。Document是一片文档,Field是字段(属性)。...,这儿需要你添加引用Microsoft mshtml组件,MSHTML是微软公司的一个COM组件,该组件封装了HTML语言中的所有元素及其属性,通过其提供的标准接口,可以访问指定网页的所有元素。...搜索的代码: 查看盘古分词文档找到高亮显示: private string Preview(string body,string keyword) {...Jquery UI模拟,下面是获取根据搜索数量最多的进行排序,得到IEnumerable集合 public IEnumerable
将GetValuesTest方法替换为如下代码,其中startup类是应用自AspnetCoreFunctionalTestDemo项目 [Fact] public void GetValuesTest...GetProjectPath(string slnName, string solutionRelativePath, Assembly startupAssembly) { string projectName...(Path.Combine(directoryInfo.FullName, solutionRelativePath, projectName)); } directoryInfo = directoryInfo.Parent...]")] public class ValuesController : Controller { // GET api/values [HttpGet,Authorize] public IEnumerable...(Path.Combine(directoryInfo.FullName, solutionRelativePath, projectName)); } directoryInfo = directoryInfo.Parent
当然,将实现类Test隐式转换为IEnumerable接口,再调用接口的Where方法也能达到同样的效果。...如果集合中的元素无法强制转换为 T 类型,则此方法将引发异常。...>()) { Console.WriteLine(item); } 运行此代码,可以输出“Bob”、“Jack”,然后会报出一个异常“无法将int强制转换为string”,这说明...Cast方法也是延迟执行实现的,只有在枚举过程中才将对象逐个强制转换为T类型。...,抛出异常 如果序列成功转换为List,并且元素数量大于0,则返回首个元素 如果序列没有成功转换为List,则尝试获取序列的遍历器,然后再调用遍历器的MoveNext方法,如果返回值为true
: public IEnumerable LoadEnablePlugins(IServiceCollection serviceCollection) { var...(); } public string CurrentPath { get; set; } public string AssemblyPath...set; } private TypeInfo PluginTypeInfo = typeof(IPluginStartup).GetTypeInfo(); public IEnumerable...foreach (var item in libaray.Assemblies) { var files = new DirectoryInfo...loader.GetPlugins().Where(m => m.Enable && m.ID.IsNotNullAndWhiteSpace()).Each(m => { var directory = new DirectoryInfo
一、简介 在上篇博客《【游戏开发】Excel表格批量转换成CSV的小工具》 中,我们介绍了如何将策划提供的Excel表格转换为轻便的CSV文件供开发人员使用。...因此我们可以直接将Excel表格转换为lua文件,这样就可以高效、方便地在Lua中使用策划配置的数据了。...Excel目录存放我们需要进行转换的Excel表格文件。LuaData目录存放转出来的Lua配置文件。Xls2Lua目录也就是我们的转表工具的目录了,它包含源代码和可直接运行的转表工具。 ...转表工具的设计结构如下图所示: ?...inDir, string outDir) 65 { 66 ClearDirectory(outDir); 67 List<string
因为其泛型参数有out关键字标识, 所以IEnumerable泛型的类型参数T支持协变性, 则可将List转化为IEnumerable(这是被继承的协变性支持的....= new List(); 7 // AddRange方法接收的参数类型为IEnumerable collection 8 // 下面的代码是传入的是...List类型的参数。...10 // 所以 IEnumerable泛型类型参数T支持协变性,所以可以 11 // 将List转化为IEnumerable(这个是继承的协变性支持的...要让编译器通过, 我们必须使用强制类型转换, 把object转换为int. 即obj = (int)obj + 10; 但是动态类型的引入到底有什么好处呢? 1,可以减少强制类型转换的使用.
此参数必须是可以强制转换为 的对象。...访问规则的继承属性。... 参数的值不能强制转换为 <see cref...DirectoryExists(path)) return null; IList result = new List...(); var dSecurity = Directory.GetAccessControl(new DirectoryInfo(path
public static IEnumerable ReferencedPlugins { get; set; } public...shadowFolder) { DirectoryInfo copyFolder; //根据当前的信任级别设置复制目录...File.Exists(filePath)) return new List(); var text = File.ReadAllText...(filePath); if (String.IsNullOrEmpty(text)) return new List();...var lines = new List(); using (var reader = new StringReader(text)) {
, IList, ICollection, IEnumerable List类是 ArrayList 类的泛型等效类。...“添加到 ArrayList 中的任何引用或值类型都将隐式地向上强制转换为 Object。如果项是值类型,则必须在将其添加到列表中时进行装箱操作,在检索时进行取消装箱操作。...强制转换以及装箱和取消装箱操作都会降低性能;在必须对大型集合进行循环访问的情况下,装箱和取消装箱的影响非常明显。”... mList = new List(); 2、List testList =new List (IEnumerable collection);...} 这时subList存储的就是所有长度大于3的元素 List.Take(n): 获得前n行 返回值为IEnumetable,T的类型与List的类型一样 E.g.: IEnumerable
领取专属 10元无门槛券
手把手带您无忧上云