Esempio n. 1
0
        public static void SetCurrentDirectory(string path)
        {
            // path validation in Path.GetFullPath()

            path = Path.GetFullPath(path);

            // We lock the directory for read-access first, to ensure path won't get deleted
            Object record = FileSystemManager.AddToOpenListForRead(path);

            try
            {
                if (!Directory.Exists(path))
                {
                    throw new IOException("", (int)IOException.IOExceptionErrorCode.DirectoryNotFound);
                }

                // This will put the actual lock on path. (also read-access)
                FileSystemManager.SetCurrentDirectory(path);
            }
            finally
            {
                // We take our lock off.
                FileSystemManager.RemoveFromOpenList(record);
            }
        }