如何读取文件夹下的所有文件名
来源:互联网 发布:算法设计与分析pdf云盘 编辑:程序博客网 时间:2024/05/19 06:38
System.IO;
FileInfo
DirectoryInfo
using System;
using System.IO;
public class NameTest
{
public static void Main()
{
// Create a reference to the current directory.
DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory);
// Create an array representing the files in the current directory.
FileInfo[] fi = di.GetFiles();
Console.WriteLine("The following files exist in the current directory:");
// Print out the names of the files in the current directory.
foreach (FileInfo fiTemp in fi)
Console.WriteLine(fiTemp.Name);
}
}
1:如何获得当前编码:当前编码默认是系统编码,
String encoding=System.getProperty("file.encoding");
encoding就是当前编码.
2,如何转换成gb2312格式编码:我给你写了个函数,用来转换
中文字符编码,转换成gb2312格式的:
/**
* inParam:需要转换的gb2312中文字符
* 返回:该中文字符对应的UTF-8编码的字符
*/
public static String toUTF(String inPara){
char temChr;
int ascChr;
int i;
String rtStr=new String("");
if(inPara==null){
inPara="";
}
for(i=0;i<inPara.length();i++){
temChr=inPara.charAt(i);
ascChr=temChr+0;
rtStr=rtStr+"&#x"+Integer.toHexString(ascChr)+";";
}
return rtStr;
}
FileInfo
DirectoryInfo
using System;
using System.IO;
public class NameTest
{
public static void Main()
{
// Create a reference to the current directory.
DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory);
// Create an array representing the files in the current directory.
FileInfo[] fi = di.GetFiles();
Console.WriteLine("The following files exist in the current directory:");
// Print out the names of the files in the current directory.
foreach (FileInfo fiTemp in fi)
Console.WriteLine(fiTemp.Name);
}
}
1:如何获得当前编码:当前编码默认是系统编码,
String encoding=System.getProperty("file.encoding");
encoding就是当前编码.
2,如何转换成gb2312格式编码:我给你写了个函数,用来转换
中文字符编码,转换成gb2312格式的:
/**
* inParam:需要转换的gb2312中文字符
* 返回:该中文字符对应的UTF-8编码的字符
*/
public static String toUTF(String inPara){
char temChr;
int ascChr;
int i;
String rtStr=new String("");
if(inPara==null){
inPara="";
}
for(i=0;i<inPara.length();i++){
temChr=inPara.charAt(i);
ascChr=temChr+0;
rtStr=rtStr+"&#x"+Integer.toHexString(ascChr)+";";
}
return rtStr;
}
- 如何读取文件夹下的所有文件名
- c++读取文件夹下的所有文件名
- C++ 读取文件夹下的所有文件名
- 如何读取文件夹下的所有文件名到TXT文件中
- PHP 递归读取指定文件夹下的所有文件名
- ubuntu C++ 读取文件夹下所有文件的文件名
- 读取,修改某个文件夹下的所有文件名
- PHP 递归读取指定文件夹下的所有文件名
- vc++ 读取指定文件夹下所有文件名
- 【C++】读取文件夹下所有文件名
- 文件夹下的所有文件名
- c++ 读取文件夹下的所有文件名(实现未知文件名也可以批量读取文件)
- java 读取某个文件夹下的所有文件夹和文件, 返回所有文件名 (转)
- java 读取某个文件夹下的所有文件夹和文件, 返回所有文件名
- 如何读取所有文件夹下的所有文件
- Linux C 读取文件夹下所有文件(包括子文件夹)的文件名
- Linux C 读取文件夹下所有文件(包括子文件夹)的文件名
- Linux C 读取文件夹下所有文件(包括子文件夹)的文件名
- 利用Hook技术实现键盘监控
- CFile操作详解
- 怎样在C++中建立删除一个文件
- 如何简单实现可执行文件的自我删除
- 文件操作:实现 建立:读,写,删除 功能
- 如何读取文件夹下的所有文件名
- C++实现文件删除
- 用VC++编程控制计算机和光驱
- 自动截屏到文件的小程序
- VB用API函数遍历指定驱动器、目录的文件
- Alloctor--- C++标准库函数
- BCB---VCL的内存管理函数
- 修改注册表,自动运行程序
- c# 验证码问题