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> ")