我有以下代码示例,其中我只想要文件名,但它显示完整路径。
public static string pathFolder = System.IO.Directory.GetCurrentDirectory() + "\\SmsFiles\\";
public static bool FilesFinish = true;
static void Main(string[] args)
{
ss = getconnected("COM7");
Thread.Sleep(10000);
if(ss)
{
Timer t = new Timer(TimerCallback, null, 0, 4000);
}
Console.ReadKey();
}
private static void TimerCallback(Object o)
{
try
{
string[] fileEntries = Directory.GetFiles(pathFolder);
if (FilesFinish)
{
FilesFinish = false;
foreach (string fileName in fileEntries)
{
var Readfile = File.ReadAllLines(fileName).Last();
string GetNumber = fileName.Substring(0, 11);}