zoukankan      html  css  js  c++  java
  • 关于异常System.IO.DirectoryNotFoundException

    什么是System.IO.DirectoryNotFoundException

    找不到文件或目录的部件时引发的异常。

    继承关系

    DirectoryNotFoundException

    例子

    using System;
    using System.IO;
    
    class Program
    {
    
        static void Main(string[] args)
        {
            try
            {
    
                //  Specify a directory name that does not exist for this demo.
                string dir = @"c:78fe9lk";
    
                // If this directory does not exist, a DirectoryNotFoundException is thrown
                // when attempting to set the current directory.
                Directory.SetCurrentDirectory(dir);
            }
            catch (DirectoryNotFoundException dirEx)
            {
                // Let the user know that the directory did not exist.
                Console.WriteLine("Directory not found: " + dirEx.Message);
            }
        }
    }

    说明

    DirectoryNotFoundException 使用值为0x80070003 的 HRESULT COR_E_DIRECTORYNOTFOUND。 请注意, DirectoryNotFoundException 当 COM 互操作程序看到 HRESULT STG_E_PATHNOTFOUND (其值为0x80030003)时,也会引发此异常。

    如果你的代码没有 PathDiscovery 权限,则此异常的错误消息可能只包含文件或目录名称,而不是完全限定的路径。

  • 相关阅读:
    innerHTML使用方法
    HDU 1426 Sudoku Killer
    Junit使用教程(一)
    HLS协议实现
    GPIO
    TraceView总结
    在kettle中实现数据验证和检查
    用户向导左右滑动页面实现之ImageSwitcher
    DWZ使用笔记
    oracle进程
  • 原文地址:https://www.cnblogs.com/yilang/p/13695135.html
Copyright © 2011-2022 走看看