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

推荐订阅源

S
SegmentFault 最新的问题
The Last Watchdog
The Last Watchdog
C
Cisco Blogs
L
LINUX DO - 热门话题
T
Tenable Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cyberwarzone
Cyberwarzone
O
OpenAI News
The Hacker News
The Hacker News
V
Vulnerabilities – Threatpost
A
Arctic Wolf
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
量子位
V2EX - 技术
V2EX - 技术
GbyAI
GbyAI
W
WeLiveSecurity
Recorded Future
Recorded Future
P
Proofpoint News Feed
Project Zero
Project Zero
P
Palo Alto Networks Blog
Microsoft Security Blog
Microsoft Security Blog
S
Security Affairs
Stack Overflow Blog
Stack Overflow Blog
B
Blog
Y
Y Combinator Blog
月光博客
月光博客
K
Kaspersky official blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Latest news
Latest news
Forbes - Security
Forbes - Security
T
Troy Hunt's Blog
T
The Blog of Author Tim Ferriss
C
Check Point Blog
D
DataBreaches.Net
MyScale Blog
MyScale Blog
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
D
Docker
P
Privacy International News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
Cyber Attacks, Cyber Crime and Cyber Security
S
Securelist
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
SecWiki News
SecWiki News
腾讯CDC
博客园 - Franky

博客园 - 秋枫

使用BizTalk Server常见问题处理 BizTalk Server中简单xml架构使用举例 CodeProject.com上微软BizTalk平台技术文章集锦 BizTalk Server 2006中使用MQSeries适配器问题处理 基于.Net平台应用程序唯一运行实例实现 使用BizTalk Server的Sql适配器出现“新事务不能登记到指定的事务处理器中”异常的处理 谈基于.net平台windows开发中的模式窗体 Visual studio 2005下xml的xsl转换调试 小提国内一些提供RSS服务的网站生成Rss文件问题 Visual studio .net 的“隐蔽性”和容易“忽略”的功能 使用sqlcmd(osql) 实用工具列出本地网内的Sql Server 服务器 《敏捷注册表》1.0使用说明书 《敏捷注册表》1.0概述 使用从BindingManagerBase.PositionChanged 事件的注意点 使用Microsoft SQL Server 2000的XML查询 asp.net中显示DataGrid控件列序号的几种方法 使用.net framewrok 1.1版System.Windows.Forms.TreeView的一个问题 使用.net framewrok 1.1版注册表API的局限和解决 使用.net framework中常用类在2.0版中的新功能
使用SaveFileDialog需要注意的情况
秋枫 · 2005-10-08 · via 博客园 - 秋枫
 

     在使用SaveFileDialog时发现如果在保存窗口文件名输入框中输入以点号分割的字符串时,无论怎么设置SaveFileDialog.AddExtension属性都不会增加扩展名。比如”123.456”,”rt.yui.eee”,那保存的文件扩展名变成了”.456”和”.eee”。相对于这个情况,我使用Word和记事本进行了测试,新生成的文件会自动加上扩展名变成123.456.txt和123.456.doc。 下面是测试代码:

SaveFileDialog saveRegFile = new SaveFileDialog();
saveRegFile.AddExtension = true;
//saveRegFile.InitialDirectory = Application.StartupPath;
saveRegFile.Filter = "reg files (*.reg)|*.reg|txt files (*.txt)|*.txt";
saveRegFile.FilterIndex = 0;
saveRegFile.RestoreDirectory = true;
saveRegFile.Title = "保存文件"; 
if (saveRegFile.ShowDialog() == DialogResult.OK)

    string fileName = saveRegFile.FileName; 
    using (File.Open(fileName, FileMode.Create)) 
   
    }
}

在VS2003和VS2005下测试得到同样的结果。解决的办法就比较简单了,判断扩展名是否正确然后修正字符串。