扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

C#涓璬irectory.getfiles鎬庝箞浣跨敤

扬州沐宇科技
2023-08-08 03:04:26
c#, directory.getfiles

鍦–#涓紝Directory.GetFiles鏂规硶鐨勪娇鐢ㄦ柟寮忓涓嬶細

using System;
using System.IO;
class Program
{
static void Main()
{
// 鎸囧畾鏂囦欢澶硅矾寰?/span>
string folderPath = @"C:\Users\username\Desktop\TestFolder";
// 鑾峰彇鏂囦欢澶逛腑鐨勬墍鏈夋枃浠?/span>
string[] files = Directory.GetFiles(folderPath);
// 閬嶅巻鏂囦欢鏁扮粍
foreach (string file in files)
{
Console.WriteLine(file);
}
}
}

鍦ㄤ笂杩扮ず渚嬩腑锛屾垜浠鍏堥€氳繃Directory.GetFiles鏂规硶鑾峰彇鎸囧畾鏂囦欢澶癸紙folderPath锛変腑鐨勬墍鏈夋枃浠讹紝骞跺皢缁撴灉瀛樺偍鍦?code>string[]鏁扮粍涓€傜劧鍚庯紝鎴戜滑浣跨敤foreach寰幆閬嶅巻鏂囦欢鏁扮粍锛屽苟灏嗘瘡涓枃浠惰矾寰勬墦鍗板埌鎺у埗鍙颁笂銆?/p>

扫码添加客服微信