专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VB Dotnet

fileexist文件路径中含有空格解决方法

发布时间:2011-06-23 15:54:52 文章来源:www.iduyao.cn 采编人员:星星草
fileexist文件路径中含有空格
各位:
fileexist文件路径中含有空格怎么处理?而且文件路径的空格事先不能确定的.
程序如下:
单击事件(物理路径pathurl存在则打开相应的文件,不存在则给出相应提示):

dim   pathurl1   as   string=pathurl.replace( "\ ", "\\ ")
pathurl1   =pathurl.replace( "   ", "\   ")            
  If   fileexists(pathurl)=   True   Then
                        Response.Write( " <script> window.open( ' "   &   pathurl1   &   " ') </script> ")
                Else
                        datacomm.ShowResult( "该文件 "   +   pathurl1   +   "不存在,请确认! ",   False)
                End   If


        Function   fileexists(ByVal   path   As   String)
                Dim   fs   As   Object
                fs   =   CreateObject( "Scripting.FileSystemObject ")
                If   Not   fs.fileexists(path)   Then

                        Return   False
                Else
                        Return   True
                End   If
                fs   =   Nothing
        End   Function

------解决方案--------------------
pathurl1 =pathurl.replace( " ", "\ ")
这一句去掉试试。
------解决方案--------------------
File.Exist 可以有空格
try
File.Exists( "C:\\Program Files\\folder.htt ") == true (C#)

why
dim pathurl1 as string=pathurl.replace( "\ ", "\\ ")
pathurl1 =pathurl.replace( " ", "\ ")
------解决方案--------------------
学习啦
------解决方案--------------------
dim pathurl1 as string=pathurl.replace( "\ ", "\\ ")
pathurl1 =pathurl.replace( " ", "\ ")
---------------------------------------------
你这两句有什么意思!
下面这样改:
pathurl2=replace(pathurl1, " ", "%20 ")


Response.Write( " <script> window.open( ' " & pathurl2 & " ') </script> ")
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: