Hi sir,
 
I am using my code to check the specific location of file is open or not here is the code below.
 public  static bool FileInUse(string path)
    {
        try
        {
            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                return false;
            }
            //return false;
        }
        catch (IOException ex)
        {
            return true;
        }
    }
this code i am calling like here below:
 
 
 foreach (string filepath1 in filepaths)
            {
                if (!FileInUse(filepath1))
                {
                    File.Delete(filepath1);
                }
                else
                {
                   //here need code to close this opened file.
                }
            }
so in the above code filepath1 is having the complete path of file.
if this file is opened i am able to get but i want it opened i have to close it through coding.
Thanks