Error:52:Bad file name or number

Error could be thrown sometimes in vb6 application ,when getting file name from specific folder from the nertwork and this folder contains hundreds of pdf files .Naming convention of that files look like this


This function throws error
strFile = Dir$(strFolder)

Error:52:Bad file name or number

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try like this one
strPath = Trim(Filepath) & Trim(strFolder) & "*.pdf"
strFile = Dir(strPath)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If that did'nt help it
write here your complete code
You may need to verify you are using the right "server" path.  Instead of using the drive letter ("X:"), make sure you use the "\\server\folder\folder" and see if that corrects your problem.  You also may need to make sure you don't try to use the "strFile" in another part of the code without making sure there is a value of "strFile".  This may be causing your problem.

If strFile <>"" then
   'Put the rest of code that needs the "strFile" value here
   'No file to use!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.