当前位置:编程学习 > C#/ASP.NET >>

新手菜鸟求助,取文件夹中的文件名

--------------------编程问答-------------------- 要用Direct类。可以得到文件夹中的文件。
再安照文件名做处理就可以了。 --------------------编程问答-------------------- 能给详细的代码吗? --------------------编程问答--------------------

 string[] directpath = Directory.GetDirectories("C:\\Users\\wlflimi.MICR3\\Desktop");

直接用这个方法取名称 --------------------编程问答-------------------- 1、取文件夹 string[] dir = Directory.GetDirectories(路径);
2、取文件 string[] file = Directory.GetFiles(路径); --------------------编程问答-------------------- Linq 学习中

 string strPath = @"E:\Picture";
            List<string> oList = new List<string>(System.IO.Directory.GetFiles(strPath, "*.jpg"));
            var query1 = from varName in oList select new { Name = varName.Replace(strPath + "\\", ""), Farther = varName.Replace(strPath + "\\", "").Replace(".jpg", "").TrimEnd(new char[] { 'a', 'b', 'c', 'd', 'e' }) };
            var query2 = from oItem in query1 group oItem by oItem.Farther;
            string strSqlTemp = "INSERT TABLE (ITEMPIN,PICTURE) VALUES('{0}','{1}')";
            string strSql = string.Empty;
            foreach (var oGroup in query2)
            {               
                var query3 = from vName in oGroup select vName.Name;
                string strPics = string.Join(",", query3.ToArray());
                strSql = string.Format(strSqlTemp, oGroup.Key, strPics);
            }
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,