কম্পিউটার টিউটোরিয়াল

C#-এ ফাইলের অস্তিত্ব যাচাই করা

আমাদের যে ফাইলটি খুঁজতে হবে তা ধরা যাক:

E:\new.txt

উপরের ফাইলের অস্তিত্ব যাচাই করতে Exists() মেথড ব্যবহার করুন:

if (File.Exists(@"E:\new.txt"))
{
    Console.WriteLine("File exists...");
}

সম্পূর্ণ উদাহরণ

using System;
using System.IO;

public class Demo
{
    public static void Main()
    {
        if (File.Exists(@"E:\new.txt"))
        {
            Console.WriteLine("File exists...");
        }
        else
        {
            Console.WriteLine("File does not exist in the E directory!");
        }
    }
}

আউটপুট

File does not exist in the E directory!
  1. হোস্টস ফাইল ব্যবহার করে উইন্ডোজে ওয়েবসাইট ব্লক করার পদ্ধতি

  2. Mac-এ ফাইল চেকসাম যাচাই করার পদ্ধতি

  3. লিনাক্সে Find কমান্ড ব্যবহার করে ফাইল খুঁজে বের করার পদ্ধতি

  4. Redis SISMEMBER: সেট সদস্যতা যাচাই করার দ্রুত পদ্ধতি