A progam that read a fild and checks if it's true
An HTML file starts with and ends with . Write a program that reads a file and checks whether that is true.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 8, 2009, 4:45 PM EST
Here is Code for that
if my answer helps you then check "Do you like this answer" check box please :)
private void button1_Click(object sender, EventArgs e)
{
string Data = File.ReadAllText("test.html");
if (Data.StartsWith(".") == true && Data.EndsWith(".") == true)
{
MessageBox.Show("Validation Success!!");
}
else
{
MessageBox.Show("Validation Failed!!");
}
}
Sam HobbsRank #107 · 20.5K reputationPosted Dec 8, 2009, 1:01 PM EST
Hiren SoniRank #694 · 3.5K reputationPosted Dec 8, 2009, 4:57 PM EST
Lalit MRank #1,186 · 1.5K reputationPosted Dec 8, 2009, 7:21 PM EST
///
/// method to check not only if a file is already open, but if the
/// but also if read and write permissions exist
///
/// the file we wish to check
///
public bool isFileOpenOrReadOnly(ref string file)
{
try
{
//first make sure it's not a read only file
if ((File.GetAttributes(file) & FileAttributes.ReadOnly) != FileAttributes.ReadOnly)
{
//first we open the file with a FileStream
using (FileStream stream = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None))
{
try
{
stream.ReadByte();
return false;
}
catch (IOException)
{
return true;
}
finally
{
stream.Close();
stream.Dispose();
}
}
}
else
return true;
}
catch (IOException)
{
return true;
}
}
more reference link --->Thanks.