public bool showOpenFileDlg(out string userFile,
string filter,
string fileToSearch,
string curDir,
string title,
bool saving)
{
userFile = "";
FileDialog fd = m_commDialog as FileDialog;
if (curDir.Length > 0 && curDir != " ")
{
DirectoryInfo di = new DirectoryInfo(curDir);
if (di.Exists)
{
fd.InitialDirectory = curDir;
}
}
if (fileToSearch != " ." && (fileToSearch.Length < 2 || fileToSearch.Substring(0, 2) != "*."))
{
fd.FileName = fileToSearch;
}
else
{
fd.FileName = "";
}
if (m_filter.Length > 0)
{
fd.Filter = m_filter;
}
else if (filter.Length > 0)
{
fd.Filter = filter;
}
fd.Title = title;
if (saving)
{
SaveFileDialog fs = m_commDialog as SaveFileDialog;
if (fs.ShowDialog() == DialogResult.OK)
{
userFile = fs.FileName;
return true;
}
else
{
return false;
}
}
else
{
OpenFileDialog fc = m_commDialog as OpenFileDialog;
if (fc.ShowDialog() == DialogResult.OK)
{
userFile = fc.FileName;
return true;
}
else
{
return false;
}
}
}