Click here to Skip to main content
15,902,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my programme when i click a particular row in DataGridView, if that row is having "\" it should pop up an error message that "\ is not allowed in name or in path". I dont how to do that.

Here is the code:
C#
namespace OVF_ImportExport
{
    public partial class Form1 : Form
    {

        string sName = "";
        string sPath = "";
                public Form1()
        {
            InitializeComponent();
        }private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
                
            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                 sName = row.Cells[0].Value.ToString();
                 sPath = row.Cells[1].Value.ToString();

            }
        }
 private void BtnCreate_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = "";
            StreamWriter file = new StreamWriter("Export.bat");
            file.WriteLine("c: ");
            file.WriteLine("cd \\");
            file.WriteLine("cd Program Files ");
            file.WriteLine("cd VMware");
            file.WriteLine("cd VMware OVF Tool");

            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                 sName = row.Cells[0].Value.ToString();
                 sName = sName.Trim();
                 sPath = row.Cells[1].Value.ToString();

              file.WriteLine("start ovftool.exe --powerOffSource vi://" + TxtUsername.Text + ":" + TxtPassword.Text + "@"
                   + TxtIP.Text + sPath + " " + "\"" + TxtBrowsepath.Text + "\\" +  sName + "\\" + sName + ".ovf" + "\"" + Environment.NewLine);

               
                
            }
            file.WriteLine("pause");
            MessageBox.Show("Batch File Created","Batch File");
            file.Close();
        }
Posted
Updated 20-Jul-15 2:19am
v2
Comments
[no name] 20-Jul-15 8:37am    
http://www.dotnetperls.com/contains

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900