获取目录中存在的文件的文件名 [英] Get File Name for the file present in the directory

查看:76
本文介绍了获取目录中存在的文件的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


i有一个目录,我知道该目录的路径

我将如何得到该目录中存在的所有文件的名称。

在c#winform中我想要检查该文件夹中是否存在该文件。

hi
i have a directory and i know the path of that directory
how i wil get the name of all the file present in that directory.
in c# winform and i aslo want to check wether file exist in that folder or not.

推荐答案

它将列出来自的所有文件该目录&该路径的子目录。



It will list all the files from that directory & subdirectory from that path.

String[] allfiles = System.IO.Directory.GetFiles("YourDirPath", "*.*", System.IO.SearchOption.AllDirectories);



列表的所有文件和文件目录-IN-A-目录的子目录 [ ^ ]


使用此代码:

Use this code:
using System.IO;

string[] fileNames = Directory.GetFiles(@"c:\MyDir\"); 
// returns:
// "c:\MyDir\my-car.BMP"
// "c:\MyDir\my-house.jpg"



查看更多来自..

Directory.GetFiles方法 [ ^ ]


http://forums.asp.net/t/1877219.aspx / 1 [ ^ ]



检查链接..希望它有帮助..
http://forums.asp.net/t/1877219.aspx/1[^]

Check the link..hope it will help..


这篇关于获取目录中存在的文件的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆