zoukankan      html  css  js  c++  java
  • 将文件及文件夹路径 转为 xml

    将文件及文件夹路径 转为 xml ,加速查询



    Public Shared Function ScanFileInfo2Xml(ByVal FolderPath As String) As XDocument Dim fiXml As XDocument fiXml = XDocument.Parse("<FileInfoList rootdir = '" & FolderPath & "'>" & AddDirFiles(FolderPath) & "</FileInfoList>") Return fiXml End Function Public Shared Function AddDirFiles(ByVal DirPath As String) As String Dim diTop As New DirectoryInfo(DirPath) Dim sr As String = "" Try For Each fi In diTop.EnumerateFiles("*", SearchOption.TopDirectoryOnly) Try ' 输出每一个文件 sr = sr & "<filename>" & fi.Name & "</filename>" Catch unAuthTop As UnauthorizedAccessException Console.WriteLine($"{unAuthTop.Message}") End Try Next For Each di In diTop.EnumerateDirectories("*") Try sr = sr & "<Directory value = '" & di.Name & "'>" & AddDirFiles(di.FullName) & "</Directory>" Catch unAuthSubDir As UnauthorizedAccessException Console.WriteLine($"unAuthSubDir: {unAuthSubDir.Message}") End Try Next Catch dirNotFound As DirectoryNotFoundException Console.WriteLine($"{dirNotFound.Message}") Catch unAuthDir As UnauthorizedAccessException Console.WriteLine($"unAuthDir: {unAuthDir.Message}") Catch longPath As PathTooLongException Console.WriteLine($"{longPath.Message}") End Try Return sr End Function
  • 相关阅读:
    kbmmw 5.14.00 发布
    关于C++ auto使用要注意的一点
    git设置socks5代理
    电子书分享网站
    spring cache相关
    intellij idea开启debug热加载/热部署
    git 多次commit合并成一次提交
    es feature一览
    数据中台
    Java Agent
  • 原文地址:https://www.cnblogs.com/MadeInChinese/p/14132940.html
Copyright © 2011-2022 走看看