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 权限,则此异常的错误消息可能只包含文件或目录名称,而不是完全限定的路径。

  • 相关阅读:
    MVC过滤器
    MVC自带的校验
    FPGA简单概述
    CAN总线扩展数据帧介绍
    简述人工智能发展的先决条件
    CAN总线标准帧
    CAN总线应用
    CAN总线优点
    CAN总线概述
    高速PCB设计注意事项
  • 原文地址:https://www.cnblogs.com/yilang/p/13695135.html
Copyright © 2011-2022 走看看