csharp中的DirectoryNotFoundException? [英] DirectoryNotFoundException in csharp?

查看:95
本文介绍了csharp中的DirectoryNotFoundException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IO.Directory.CreateDirectory("S:\\ Sample");

当我运行以上语句时,我会得到

例外
找不到路径"S:\ Sample"的一部分.

有什么主意请让我知道...

IO.Directory.CreateDirectory("S:\\Sample");

when i run the above statement i am getting
the exception as

Could not find a part of the path ''S:\Sample''.

any idea plz let me know...

推荐答案

我在错误消息中搜索并找到了这个内容:

http://support.microsoft.com/kb/827421 [
I googled the error message and found this:

http://support.microsoft.com/kb/827421[^]

Let me know if it solves your problem.


//如果已经存在,请包含以下名称空间ignore
使用System.IO;

//如果您正在Windows或Web应用程序上工作,并且您具有从用户帐户访问驱动器的所需权限,则通常在所需的源驱动器不可用或相关文件夹不存在时引发此类异常,因此请检查
它存在或在上述路径中创建文件夹将解决

//如果驱动器和文件夹存在,则您无权访问它,或者如果它是外部设备,则它可能被禁用
// please include the below namespace if already exists ignore
using System.IO;

// if you r working in on a windows or web application and u have desired permissions to access the drives from your user account then such exception usually is raised when the desired source drive is not available or the concerned folder does not exists hence check that
it exists or create the folder in the above path it would solve

// incase the drive and the folder exists then you don''t have the permission to access it or if its a external device then it might be disabled


异常表示S驱动器您无法使用它来创建文件夹.
The exception means that the S drive is not accessible to you, for creating folders.


这篇关于csharp中的DirectoryNotFoundException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆