किसी छिपी हुई फ़ाइल को खोलने के लिए, पहले उसे दृश्यमान बनाएं। आप इस पर सेट छिपी हुई विशेषता को हटाकर ऐसा कर सकते हैं -
FileInfo file= new FileInfo(Environment.CurrentDirectory + @"\myFile.txt"); file.Attributes &= ~FileAttributes.Hidden;
अब इसे सामान्य टेक्स्ट फाइल की तरह ट्रीट करें और इसे ओपन करें। सामग्री पढ़ें -
using (StreamReader sr = new StreamReader("myFile.txt")) {
string line;
while ((line = sr.ReadLine()) != null) {
Console.WriteLine(line);
}
} पढ़ने के बाद, फ़ाइल को छिपाने के लिए विशेषता को फिर से छुपा के रूप में सेट करें -
file.Attributes |= FileAttributes.Hidden;