checking for file existence
-
how can i code to check for the existence of a particular text file in a drive and then call for a dialogue form if the file does not exist
ma coding life
Hello,
ploxy wrote:
how can i code to check for the existence of a particular text file in a drive
Have a look at System.IO.File namespace and "Exists" method.
ploxy wrote:
and then call for a dialogue form if the file does not exist
The System.Windows.Forms.MessageBox with it's static "Show" method will do that. Hope it helps! All the best, Martin
-
how can i code to check for the existence of a particular text file in a drive and then call for a dialogue form if the file does not exist
ma coding life
if (!File.Exists(filename)) {
filename=null;
using (OpenFileDialog dlg=new OpenFileDialog()) {
... dlg properties = values;
if (dlg.Show()==DialogResult.OK) filename=dlg.FileName;
}
}
if (filename!=null) ... // read the file:)
Luc Pattyn [My Articles] [Forum Guidelines]