文件系统文件名转义? C# [英] Filesystem filename escape? C#

查看:224
本文介绍了文件系统文件名转义? C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我允许用户选择他想要的任何用户名,它可以是任何东西,如

I am allowing the user to choose any username he wants and it can be anything at all such as

AC♀¿!$"Man'@

现在我需要为他创建一个目录,我使用什么功能逃避文本,所以我没有FS问题/异常?

Now i need to create a directory for him. What function i use to escape the text so i dont a FS problem/exception?

推荐答案

使用 Path.GetInvalidFileNameChars Path.GetInvalidPathChars 以检查要删除的字符。

Use Path.GetInvalidFileNameChars or Path.GetInvalidPathChars to check for characters to remove.

http://msdn.microsoft.com/en-us/library/system.io .path.getinvalidfilenamechars.aspx

这篇关于文件系统文件名转义? C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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