2

I'm creating a very simple application that will select files from local drive or from PC connected in a network. Application has a "checkbox" that can be checked True or False. Is it right to connect from Network location?? How can I create file browse button with it?

private void connect()
{
   try
   {
       if (checkbox1.Checked == false)
       {
          FilePath = @"C:\FILE";
       }
       else
       {
          FilePath = @"\\192.168.0.2\file\"; // That I want Is it work?
       }
       strConn = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + FilePath + @"\;Extensions=csv,txt";
       Connect = new OdbcConnection(strConn);
       Connect.Open();
   }
   catch (Exception Ex)
   {
       MessageBox.Show(Ex.Message);
   }
}
reVerse
  • 35,075
  • 22
  • 89
  • 84
Solution
  • 164
  • 1
  • 2
  • 11
  • 1
    So what is the problem? We expect you do to debugging and come here WITH AN ERROR DESCRIPTION, not crying and not even telling us what you think is wrong. – TomTom Nov 21 '14 at 09:55
  • Yes it's correct but didn't work on Checked event. These are "checkbox1.Checked" and 'ELSE' usage correct? – Solution Nov 24 '14 at 02:21

1 Answers1

3

You want to open a file browser on the network ? Did you try OpenFileDialog ? It works on network path too, You can use it like this:

OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = FilePath;
openFileDialog1.ShowDialog();
Ludovic Feltz
  • 11,416
  • 4
  • 47
  • 63
  • He quite explicitly does not want to open a file browser on the network. Amazing answer. Read the question. – TomTom Nov 21 '14 at 09:56
  • @TomTom I don't really understood his question but i tried to help him ! Stop critic and help ! What does `How can I create file browse button` mean for you? – Ludovic Feltz Nov 21 '14 at 09:58
  • Thanks for your answer it's very helpful then Exactly I just wanted file selection with two way - 1st local machine, 2nd network shared folder – Solution Nov 24 '14 at 02:22
  • Did it solved your problem? Can you put the answer as resolved? – Ludovic Feltz Nov 25 '14 at 09:58