本文介绍了使用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#
发布评论