文件名

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

问题描述




如何使用.NET 1.1检查字符串是否包含有效文件名

for winxp?


有问题的应用程序有一个文本框,用户可以在其中输入
filename和文件名。它不应该被允许输入路径

+ filename就像c:\ tmp \ myfile.log"或相对路径.. \tmp

\ myfile.log" - 不应该允许目录信息,只允许文件名。


任何建议。

Hi,

How can check using .NET 1.1 that a string contains a valid filename
for winxp?

The application in question has a textbox where user can enter
filename and only the filename. It should not allowed to enter path
+filename like "c:\tmp\myfile.log" or relative paths "..\tmp
\myfile.log" - no directory info should be allowed, only the filename.

Any suggestions.

推荐答案





只需检查你的字符串,确保没有出现\

..IndexOf(" \");

Just check your string to make sure there are no occurences of \
..IndexOf("\");


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

05-26 13:07
查看更多