如何判断给定路径是文件还是文件夹?
使用 Jscript 确定给定路径是文件夹还是文件的最简单方法是什么?
what is the simplest way to determine if a given path is a folder or file using Jscript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有说你在什么环境下工作。如果您的意思是 JScript 中的 < a href="http://msdn.microsoft.com/en-us/library/ms950396.aspx" rel="nofollow">Windows 脚本 环境,那么您可以使用
Scripting.FileSystemObject
对象:You didn't say in what environment you're working. If you mean JScript in a Windows Scripting environment, then you can use the
Scripting.FileSystemObject
object:仅靠 JavaScript 我知道你做不到。但是,如果您知道文件的扩展名,则可以对文件进行一些验证。这里看一个例子。
JS
HTML
这种技术仍然不是最好的方法,因为您可以篡改文件以更改其扩展名,或者您可以通过基于给定的有效扩展名添加有效扩展名来重命名文件文件。
With JavaScript alone I know you cant. But you can do some validation with a file if you know its extension. Here look an example.
JS
HTML
This techniques still not the best way as in you can tampered a file to change its extension or you can rename a file by adding a valid extension base on the given valid file.