Wednesday 10 September 2014

check file is already open or not in C#

if (File.Exists(newPath))
                    {
                        try
                        {
                            using (FileStream fs = File.Open(newPath, FileMode.Open))
                            {
                                if (fs == null)
                                {

                                }
                            }
                        }
                        catch (UnauthorizedAccessException e)
                        {
                            MessageBox.Show(e.Message.ToString());

                        }
                    }

No comments:

Post a Comment