Spaces not recognized during setup installation

Hi

i have a problem while installing my setup . My default installation path is c:\program files\

There is space in between 'Program files' , my process stops. but it works fine when i install my setup in another spaceless location like c:\sample\
 
My project involves one sample.sta file. i have kept sample.sta in the project bin folder and i refer the file using Application.startuppath

very urgent

pls help
thanx in advance
lword
lwordAsked:
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.

Jeff CertainCommented:
Have you tried using the old DOS-Compatible folder name (C:\Progra~1) ?
0
Mikal613Commented:
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Public Function GetShortPath(strFileName As String) As String
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim lngRes As Long, strPath As String
    'Create a buffer
    strPath = String$(165, 0)
    'retrieve the short pathname
    lngRes = GetShortPathName(strFileName, strPath, 164)
    'remove all unnecessary chr$(0)'s
    GetShortPath = Left$(strPath, lngRes)
End Function
Private Sub Form_Load()
    MsgBox GetShortPath("c:\Program Files\")
End Sub
0
newmanth63Commented:
Are you using a setup project in Visual Studio?  If you are, you can designate the Program Files directory using the System Folder Property [ProgramFilesFolder].  You would then add the subdirectory name after this, also using a System Folder Property if desired.  

From what you had written, I don't think you're using a setup project to deploy your app, but rather, a reference of some sort to your file (a shortcut?).  Perhaps you can try using double quotes (" ") around the path, as this may help.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

lwordAuthor Commented:
It works with DOS-Compatible folder name (C:\Progra~1)

how do i check for spaces in the folder name of Application.Startuppath string and replace the same with DOS-Compatible names


For example my Application.Startuppath looks likes this

Application.Startuppath = "C:\Program Files\Local1 settings\sample.txt

Then  i need the replced string as

Application.Startuppath = " "C:\Progra~!\Local1~1\sample.txt


pls help

lword

0
Jeff CertainCommented:
Mikal613's code (see above) has an API call which retrieves the short file name for you....
0
lwordAuthor Commented:


In the Mikal613's code I didn't understand the following lines of code

    strPath = String$(165, 0)
    lngRes = GetShortPathName(strFileName, strPath, 164)
    GetShortPath = Left$(strPath, lngRes)

1) Is String$ and Left$ function works with vb.net ? I tried , doesn't work in vb.net?
2) I'm confused why he used 165 and 164 and what is the purpose of using it

0
Jeff CertainCommented:
Replace String$(165,0) etc with

strPath = new string("0",165) ' Create a 165-character buffer
lngRes = GetShortPathName(strFileName, strPath, 164) ' Retrieve up to 164 characters from the short path name
return strPath.Substring(0, lngRes) ' Trim excess characters from the buffer and return the result
0

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
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
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.