Esempio n. 1
0
        public static void Delete(string path)
        {
            Path.Validate(path);
            if (Directory.Exists(path))
            {
                throw new UnauthorizedAccessException(Locale.GetText("{0} is a directory", path));
            }

            string DirName = Path.GetDirectoryName(path);

            if (DirName != String.Empty && !Directory.Exists(DirName))
            {
                throw new DirectoryNotFoundException(Locale.GetText("Could not find a part of the path \"{0}\".", path));
            }

            SecurityManager.EnsureElevatedPermissions();             // this is a no-op outside moonlight

            MonoIOError error;

            if (!MonoIO.DeleteFile(path, out error))
            {
                if (error != MonoIOError.ERROR_FILE_NOT_FOUND)
                {
                    throw MonoIO.GetException(path, error);
                }
            }
        }