C#鐨刣irectory.exists鏂规硶鎬庝箞浣跨敤
鍦–#涓紝鍙互浣跨敤Directory.Exists()
鏂规硶鏉ユ鏌ユ寚瀹氱殑鐩綍鏄惁瀛樺湪銆傝鏂规硶杩斿洖涓€涓竷灏斿€硷紝琛ㄧず鐩綍鏄惁瀛樺湪銆?/p>
浠ヤ笅鏄娇鐢?code>Directory.Exists()鏂规硶鐨勭ず渚嬶細
string path = @"C:\Example\Directory";
if (Directory.Exists(path))
{
Console.WriteLine("鐩綍瀛樺湪");
}
else
{
Console.WriteLine("鐩綍涓嶅瓨鍦?quot;);
}
鍦ㄤ笂闈㈢殑绀轰緥涓紝鎴戜滑棣栧厛鎸囧畾浜嗕竴涓洰褰曡矾寰?code>path銆傜劧鍚庯紝浣跨敤Directory.Exists()
鏂规硶妫€鏌ヨ鐩綍鏄惁瀛樺湪銆傚鏋滃瓨鍦紝鎴戜滑杈撳嚭"鐩綍瀛樺湪"锛涘鏋滀笉瀛樺湪锛屾垜浠緭鍑?quot;鐩綍涓嶅瓨鍦?quot;銆?/p>