使用XMLTextReader进行C#

编程入门 行业动态 更新时间:2024-10-21 09:48:18
本文介绍了使用XMLTextReader进行C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好我想知道如何使用XMLTextReader读取包含xml文件的文件夹,并获取文件夹中的文件名而不是实际路径。打开任何建议。

Hello I would like to know how I can use XMLTextReader to read a folder containing xml files and get the file names in the folder not the actual path. Open to any suggestions.

推荐答案

检查链接 - www.csharp-examples/get-files-from-directory/ [ ^ ] Hi, Check link - www.csharp-examples/get-files-from-directory/[^]

XMLTextReader [ ^ ]没有提供从目录中获取文件名的功能。 如果你想枚举目录和文件,请检查:如何:枚举目录和文件 [ ^ ] XMLTextReader[^] does not provide such of functionality to fetch file names from directory. If you would like to enumerate directories and files, check this: How to: Enumerate Directories and Files[^]

正如PIEBALDconsult所说,System.IO命名空间足以处理目录和文件。 System.IO命名空间,有两个用于处理目录和文件的重要类,它们是 FileInfo 类和 DirectoryInfo 类。 FileInfo - 用于处理文件。 DirectoryInfo - 用于处理目录。这是获取文件夹文件名的代码。 Hi, As PIEBALDconsult said, System.IO namespace is enough for dealing with Directories and Files. The System.IO namespace, there are two important classes for working with directories and files, they are FileInfo class and DirectoryInfo class. FileInfo - For handling files. DirectoryInfo - For handling directories. here is the code for getting file names of a folder. DirectoryInfo myDirectory = new DirectoryInfo("Directory path here");//Getting object reference for specified directory foreach(FileInfo myFile in myDirectory.GetFiles())//here GetFiles() returns array of FileInfo objects { MessageBox.Show(myFile.Name);//Name - gives just the File Name, not the full path MessageBox.Show(myFile.FullName);//FullName - gives File Name with full path }

更多推荐

使用XMLTextReader进行C#

本文发布于:2023-11-07 06:13:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565753.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:XMLTextReader

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!