Issue opening file using WinForms application (Open file dialog) where file location is OneDrive

Eswar Chaitanya Darsi 1 Reputation point
2021-10-12T10:52:54.273+00:00

Hi,

I am seeing an issue with File Open Dialog when I try to open a file from OneDrive location mapped on my machine.

Issue / Steps to reproduce:

  1. Copy any file (ex: excel file) to OneDrive
  2. Double click and open the file from OneDrive location to edit
  3. From any windows forms application (.NET Framework 4.8), when I try to open the same file using File dialog window I get an error message "This file is in use. Enter a new name or close the file that's open in another program" public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    openFileDialog1 = new OpenFileDialog();
    }
         private void button1_Click(object sender, EventArgs e)  
         {  
             openFileDialog1.InitialDirectory = "C:\\";  
             var result = openFileDialog1.ShowDialog();  
             if(result == DialogResult.OK)  
             textBox1.Text = openFileDialog1.FileName;  
         }  
     }  
    

139829-capture.png

This issue is not reproducible when I open the file from any local/network shared directory.

Developer technologies | Windows Forms
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.