Business.MediaEncoderBusiness.IsFileLocked C# (CSharp) Метод

IsFileLocked() приватный Метод

Returns whether specified file is in use.
private IsFileLocked ( string fileName ) : bool
fileName string
Результат bool
        private bool IsFileLocked(string fileName) {
            FileStream stream = null;

            try {
                stream = (new FileInfo(fileName)).Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
            }
            catch (IOException) {
                //the file is unavailable because it is:
                //still being written to
                //or being processed by another thread
                //or does not exist (has already been processed)
                return true;
            }
            finally {
                if (stream != null)
                    stream.Close();
            }

            //file is not locked
            return false;
        }