![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | HELP! fileExist function always return 'FALSE' HI all, I have a problem when trying to pass a string into the fileExist function. the code will get the filename from sql database, and pass into the fileExist function. then i use: filename=rs('field') if fs.fileExist(filename) then fs.Deletefile(filename) end I've tried to write out the filename, it show me a correct path and filename to the path, whille i changed the filename to string "C:\path \file" it works fine. however when i use a variable: filename, the fileExist always return "false" anyone can tell me how to solve the problem? thank you. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: HELP! fileExist function always return 'FALSE' <youu917@xxxxxx> wrote in message news:afee6132-be4f-45c2-ae0d-94447793ef52@xxxxxx Quote: > HI all, > > I have a problem when trying to pass a string into the fileExist > function. > the code will get the filename from sql database, and pass into the > fileExist function. > then i use: filename=rs('field') > if fs.fileExist(filename) then > fs.Deletefile(filename) > end > > I've tried to write out the filename, it show me a correct path and > filename to the path, whille i changed the filename to string "C:\path > \file" it works fine. however when i use a variable: filename, the > fileExist always return "false" > > anyone can tell me how to solve the problem? > thank you. supposed to be VB Script? Let's have the actual fragment from your program! |
My System Specs![]() |
| | #3 (permalink) |
| | Re: HELP! fileExist function always return 'FALSE' youu917@xxxxxx schrieb: Quote: > HI all, > > I have a problem when trying to pass a string into the fileExist > function. > the code will get the filename from sql database, and pass into the > fileExist function. Quote: > then i use: filename=rs('field') > if fs.fileExist(filename) then > fs.Deletefile(filename) > end filename = rs( "field" ) MsgBox ">" & filename & "<" If fs.FileExists( filename ) Then fs.DeleteFile filename End If to check for whitespace. If there are leading or trailing blanks, use filename = Trim( rs( "field" ) ) for other whitespace use (or ask for) a RegExp. Quote: > I've tried to write out the filename, it show me a correct path and > filename to the path, whille i changed the filename to string "C:\path > \file" it works fine. however when i use a variable: filename, the > fileExist always return "false" > > anyone can tell me how to solve the problem? > thank you. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: HELP! fileExist function always return 'FALSE' "ekkehard.horner" <ekkehard.horner@xxxxxx> wrote in message news:4a2e42fc$0$32676$9b4e6d93@xxxxxx-online.net... Quote: > youu917@xxxxxx schrieb: Quote: > > HI all, > > > > I have a problem when trying to pass a string into the fileExist > > function. > > the code will get the filename from sql database, and pass into the > > fileExist function. > change this: Quote: > > then i use: filename=rs('field') > > if fs.fileExist(filename) then > > fs.Deletefile(filename) > > end > to: > filename = rs( "field" ) > MsgBox ">" & filename & "<" > If fs.FileExists( filename ) Then > fs.DeleteFile filename > End If > > to check for whitespace. If there are leading or trailing blanks, use > > filename = Trim( rs( "field" ) ) > > for other whitespace use (or ask for) a RegExp. > Quote: > > I've tried to write out the filename, it show me a correct path and > > filename to the path, whille i changed the filename to string "C:\path > > \file" it works fine. however when i use a variable: filename, the > > fileExist always return "false" > > > > anyone can tell me how to solve the problem? > > thank you. leading white space does. Also, it seems the .FileExists method does not like the filespec to be quoted. filename = Trim(Replace(filename, Chr(34), "")) -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| RegEx to return False if input is invalid. | VB Script | |||
| Test-Path '' -IsValid does not return False but fails. Is this OK? | PowerShell | |||
| How to return a specific type from a function | PowerShell | |||
| return keyword in trap function | PowerShell | |||
| Info: Can you Type a return from a function. | PowerShell | |||