遍歷指定資料夾中的檔案,讀取MSN格式的XML檔案

2021-04-14 23:49:42 字數 4260 閱讀 4576

using system;

using system.io;

using system.text;

using system.xml;

using system.collections;

namespace documentutility

#endregion

#region setcommand

///

/// directoryproc test.

///

public void setcommand(string strcommand)

#endregion

#region searchdirectory

///

/// search directory method。

///

/// strdirectorypath:the current target searched directory path.

/// strsearcheddirectoryname:the searched directory's name.

///

private void searchdirectory(string strdirectorypath, string strsearcheddirectoryname)

else if (strtargetdirname.length > strsearcheddirectoryname.length)

}searchdirectory(strdir, strsearcheddirectoryname);}}

#endregion

#region parsedirectory

///

/// parse directory

///

///

///

protected void parsedirectory(string strpath, string strfilter)

string files = directory.getfiles(strpath, strfilter);

if (files.length > 0)}}

#endregion

#region getfilespath

///

/// get files's path

///

/// strtargetdirectory:the target directory's path.

/// strfiletype:the file's extend name.

///

private arraylist getfilespath(string strtargetdirectory, string strfilefilter)

}return arfilespathlist;

}#endregion

#region readfile

///

/// read file

///

/// strtargetfilepath:the target file's path.

/// strfilecontent:the file's content.

///

private bool readfile(string strtargetfilepath, ref string strfilecontent)

}catch (system.io.ioexception e)

}else

return blnreadflag;

}#endregion

#region readxmlfilefromnode

public void readxmlfile(string strxmlfilepath)

#endregion

#region readxmlfilefromnode

private void readxmlfilefromnode(xmlnode xnod, int32 intlevel)

//check

if (xnod.haschildnodes)}}

}#endregion

#region getcommand

///

/// get command

///

///

private void getcommand(string strcommand)

#endregion

#region commandprocess

///

/// command processed

///

///

private void commandprocess(string strcommand)

}#endregion

#region commandformat

///

/// command formated

///

///

///

private string commandformat(string strcommand)

#endregion

#region listalldirectorypaths

///

/// list all directory paths

///

///

private void listalldirectorypaths(string strpath)

}#endregion

#region listtargetdirectorypaths

///

/// list target directory's paths

///

///

///

private void listtargetdirectorypaths(string strpath, string strsearcheddirectoryname)

#endregion

#region listtargetfilespath

///

/// list target files's path

///

///

///

private void listtargetfilespath(string strdirectorypath,string strfiletype)

//filespathlist = new arraylist();

arraylist arfilespathtmp = new arraylist();

//try

////    }

//}//catch (system.io.ioexception e)

//try

}catch (system.io.ioexception e)

}#endregion

#region getxmlfilecontent

///

/// get xml file's content

///

///

private void getxmlfilecontent(string strxmlfilepath)

#endregion

#region msn's xml file process

#region readxmlfilefrom

public void readmsnxmlfile(string strxmlfilepath)

#endregion

#region readmsnxmlfilefromnode

private void readmsnxmlfilefromnode(xmlnode xnod, int32 intlevel)

else

}else if (xnodattribute.name == "date")

else if (xnodattribute.name == "time")

else if (xnodattribute.name == "style")

}//check child nodes

if (xnod.haschildnodes)}}

}#endregion

#endregion

#region disposeed

///

/// disposeed all

///

public void disposeed()

#endregion}}

C 遍歷指定資料夾中的所有檔案和子資料夾

參考 directoryinfo thefolder new directoryinfo folderfullname 遍歷資料夾 foreach directoryinfo nextfolder in thefolder.getdirectories this.listbox1.items.add...

C 遍歷指定資料夾中的所有檔案

c 遍歷指定資料夾中的所有檔案 directoryinfo thefolder new directoryinfo folderfullname 遍歷資料夾 foreach directoryinfo nextfolder in thefolder.getdirectories this.listb...

C 遍歷指定資料夾中的所有檔案

c 遍歷指定資料夾中的所有檔案 directoryinfo thefolder new directoryinfo folderfullname 遍歷資料夾 foreach directoryinfo nextfolder in thefolder.getdirectories this.listb...