Greetings,
I have a "newbie" question in relation to opening files from C#. I have
a Windows form where I allow the user to type in a file extension in a
text box (e.g., "xls"). I then take that extension and use that as my
filter criteria for the File Open dialog.
Once the user selects a file with that extension (from the File Open
dialog), I simply want to open that file (whether it is an .xls file,
.txt file, etc.). I am attempting to open the file using the
"System.IO.File.Open" command, but nothing seems to happen. Any ideas?
Thanks in advance!
************************************************** ******
private void btnOpenFile_Click(object sender, System.EventArgs e)
{
string strExt = this.txtFileExtension.Text;
strExt = strExt + " Files|*." + strExt;
this.openFileDialog1.InitialDirectory = @"C:\";
this.openFileDialog1.Filter = strExt;
if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
txtSource.Text = openFileDialog1.FileName;
else
txtSource.Text = "";
System.IO.File.Open(txtSource.Text, FileMode.Open,
FileAccess.Read, FileShare.None);
}
*** Sent via Developersdex http://www.developersdex.com ***