Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select the file which is already opened using OpenFileDialog

I am trying to select the file which is already opened in quickbook software.

code :

 OpenFileDialog ofdBrowseVInv = new OpenFileDialog();

            ofdBrowseVInv.Title = "Locate QuickBook Company File";
            ofdBrowseVInv.Filter = "QuickBook Company File (*.qbw,*.qbw)|*.qbw;*.qbm";
            ofdBrowseVInv.FileName = "";


           if (ofdBrowseVInv.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string strfilename = ofdBrowseVInv.InitialDirectory + ofdBrowseVInv.FileName;

            }

After selecting the file .. i am getting message : File in use

can any one tell me how can i select the file which is already opened...

File in use Screen shot

like image 203
Kavitha Avatar asked Mar 12 '14 05:03

Kavitha


2 Answers

The following code seems to help:

ofdBrowseVInv.ValidateNames = false;

see more here http://social.msdn.microsoft.com/Forums/vstudio/en-US/56fbbf9b-31d5-4e89-be85-83d9cb1d538c/openfiledialog-this-file-is-in-use?forum=netfxbcl

like image 106
Harry Avatar answered Sep 20 '22 15:09

Harry


This code worked for me perfectly.

ofdBrowseVInv.ValidateNames = false;
like image 29
Zico Avatar answered Sep 19 '22 15:09

Zico