随笔分类 - Utility
摘要:DataTable 转 XLSX public string DataTableToXlsx(DataTable vContent, string vOutputFilePath) { string result; try { SLDocument sldocument = new SLDocume
阅读全文
摘要:Xlsx 转 DataTable public DataTable XlsxToDataTable(string vFilePath, string vSheetName) { DataTable dataTable = new DataTable(); try { SLDocument sldoc
阅读全文
摘要:DataTabel 转 CSV 文件 public string DataTableToCsv(DataTable vContent, string vOutputFilePath) { string result; try { if (File.Exists(vOutputFilePath)) {
阅读全文
摘要:CSV文件转DataTable public DataTable CsvToDataTable(string vFilePath) { DataTable dataTable = new DataTable(); try { TextFieldParser textFieldParser = new
阅读全文
摘要:获取FTP文件目录下的所有文件信息 public string[] ftpDirDetail(string ftpPath, string user_name, string pass_word) { WebResponse webresp = null; StreamReader ftpFileL
阅读全文
摘要:创建一个Excel文件 /// <param name="filePath">filePath 为Excel保存的路径</param> public static void CreateExcel(string filePath) { Excel.Application excel = new Ex
阅读全文
摘要:DataTable的列操作 public DataTable GenerateTable() { //对Table1添加列名,并设置列值类型 DataTable dt1 = new DataTable();//创建Table dt1.Columns.Add("ID", typeof(string))
阅读全文
摘要:获取文件目录下的文件 //方法一:獲取目錄下所有文件 var dirinfo = new DirectoryInfo(path1); FileInfo[] fileinfo = dirinfo.GetFiles(); //獲取目錄下所有匹配的文件 //FileInfo[] fileinfo = di
阅读全文
摘要:C#中直接执行SQL的方法 查询语句: public static DataTable GetSelectResult() { DataTable dtResult; dtResult = new DataTable(); try { using (OracleConnection oc = new
阅读全文
摘要:调用配置好的邮件服务器 Send Mail public void SendMail(string vMailFrom, string vMailName, string vMailPass, string vMailPort, string vMailHost, string vMailPri,
阅读全文
摘要:利用正则表达式按文件类型查找文件 public string [] getFileName() { string [] AAFileNameList; string strFileNameList = ""; string localFilePath = @"D:\AAFile\"; if (!Di
阅读全文
摘要:FTP的文档上传功能实现 public object UploadFile(String filename, string targetDir, string hostname, string username, string password) { object resObj; string UR
阅读全文
摘要:调用cmd.exe 连接磁盘 public string connectFTP(string vPath, string vUID, string vPassword) { string errormsg = ""; Process proc = new Process(); try { proc.
阅读全文
摘要:XML文件解析帮助类 class ReadXMLHelper { #region 读取XML配置文件 /// <summary> /// 读取XML配置文件 失败返回null /// </summary> /// <param name="filePath">xml文件路径</param> ///
阅读全文
摘要:String 转为 List public string StringToList(string aa) { string bb1 = "("; if (!string.IsNullOrEmpty(aa.Trim())) { string[] bb = aa.Split(new string[] {
阅读全文
摘要:字符串MD5 加密 public string getMd5String(string input) { // Create a new instance of the MD5CryptoServiceProvider object. MD5 md5Hasher = MD5.Create(); //
阅读全文
摘要:将String转换为UTF-8 格式 public string UTF8Convert(string str) { if (str.Trim() != "") { string ascii_data = ""; byte[] t_byte = Encoding.UTF8.GetBytes(str)
阅读全文
摘要:通过cmd调用7z软件实现压缩和解压缩文件 压缩文件: public object CompressZipFile(string sourceFile, string destinationFile) { object resObj; Process process = new Process();
阅读全文
摘要:C#实现TXT文档转DataTable 代码: public DataTable TXTToDataTable(string fileName, string columnName) { DataTable dt = new DataTable(); FileStream fs = new File
阅读全文
摘要:C#关于 Excel文件转DataTable、转TXT文本的实现 FileToDataTable /// <summary> /// /// </summary> /// <param name="fileName">文件的路径Path+FileName</param> /// <param nam
阅读全文

浙公网安备 33010602011771号