|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace PerformanceSolutions.WinForms
{
public partial class LogFileDlg : Form
{
private string _FileName = string.Empty;
private string _FileType = string.Empty;
public string FileName
{
get { return _FileName; }
}
public string FileType
{
get { return _FileType; }
}
public LogFileDlg()
{
InitializeComponent();
}
private void btnBrowse_Click(object sender, EventArgs e)
{
DlgOpenFile.Filter = "Csv File(*.csv)|*.csv|Xml File(*.xml)|*.xml";
DlgOpenFile.FilterIndex = 1;
DlgOpenFile.CheckPathExists = true;
DlgOpenFile.RestoreDirectory = true;
DlgOpenFile.Title = "Choose a file name";
if (DlgOpenFile.ShowDialog() == DialogResult.OK)
{
txtFile.Text = DlgOpenFile.FileName;
}
else
{
return; //Cancelled
}
}
private void btnOK_Click(object sender, EventArgs e)
{
if (txtFile.Text.Length > 0)
{
_FileName = txtFile.Text;
_FileType = FileName.Substring(FileName.Length - 4);
if (_FileType.ToLower() != ".csv" && _FileType.ToLower() != ".xml")
{
MessageBox.Show("File extension can be only .csv or .xml.", "Wrong file type...", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtFile.Focus();
return;
}
}
else
{
MessageBox.Show("Please enter a file name.", "File name missing...", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtFile.Focus();
return;
}
this.DialogResult = DialogResult.OK;
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.