惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - noahsky

Connection to https://dl-ssl.google.com refused 由于线程停在某个无法进行垃圾回收的点(可能是因为已对代码进行了优化),因此无法计算表达式的值的解决 3.1,ASP.NET MVC控制器概述(C#) [翻译]ASP.NET MVC 指南 "ORA-01460: 转换请求无法实现或不合理"及C#操作Blob总结 - noahsky - 博客园 你被移动增值了吗? sql2005数据库,在新增或更新数据时出现超时现象 关于c#的连接池(以OracleConneciton为例) 使用Access时,碰到的没有解决的问题 少一个逗号出的错误 Web上传文件的原理及实现[转] (翻译)从底层了解ASP.NET体系结构 [转] HTTP请求过程简介[转] Http 请求处理流程[转] sql2000安装在win2003后只有在本机才能访问,局域网内其他机器不能访问 sql2000数据库在企业管理器中显示置疑(suspect),在查询分析器不显示。在企业管理器中附加:提示错误823 .net 必知 面向对象 C# 比较牛的代码
System.IO.DirectoryNotFoundException: 未能找到路径“....”的一部分
noahsky · 2009-09-24 · via 博客园 - noahsky

今天遇到如标题的错误,示例代码如下:

string dirFullName = @"E:\aaa ";
DirectoryInfo dir 
= new DirectoryInfo(dirFullName);
FileInfo[] fs 
= dir.GetFiles();

注:其中在第一行字符aaa后面有一个空格。于是第三句代码便会上述错误。用Reflector查看DirectoryInfo的GetFiles代码,发现在是调用NormalizePathFast中

if (fullCheck)
    {
        path 
= path.TrimEnd(new char[0]);
        CheckInvalidPathChars(path);
    }

第三行出了错,又查了一下string的TrimEnd方法如下:

Code

原来最终在这里把字符串中空格给过滤了。而操作系统是允许建立名称最后是空格的文件夹的。于是再调用GetFiles方法时,原来的文件名已经变了,把空格过滤了。于是便出现了这个错误。
解决方法:
1,建立没有空白字符的文件夹名,但这个与操作系统冲突。
2,在使用文件夹名时加上"\",如

string dirFullName = @"E:\aaa \";

但这样也会增加操作。。
还有更好的方法吗?????