By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,728 Members | 2,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,728 IT Pros & Developers. It's quick & easy.

File path (contains special characters) problem when passing as input to API function.

P: n/a
Hi All,

I am using an API function, which takes file path as an input.
When file path contains special characters (@,#,$,%,&,^, etc), API function
gives an error as "Unable to open input file".
Same file path containing special characters works fine in one machine, but
doesn't work in other.
I am using following API function to get short file path.

Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As
String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal cchBuffer As
Integer) As Integer
Using this I get expected result for most of the time. Bu still in some
combinations I get error. e.g. when file is in "D:\Bin$\hello.wav"

Please, can anyone give me some details about this problem and how to solve
it.

Thanks in Advance.

Sakharam Phapale
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
What is exactly you want to do, because maybe you don't need the api.

Greetz Peter

"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am using an API function, which takes file path as an input.
When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file".
Same file path containing special characters works fine in one machine, but doesn't work in other.
I am using following API function to get short file path.

Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal cchBuffer As Integer) As Integer
Using this I get expected result for most of the time. Bu still in some
combinations I get error. e.g. when file is in "D:\Bin$\hello.wav"

Please, can anyone give me some details about this problem and how to solve it.

Thanks in Advance.

Sakharam Phapale

Nov 21 '05 #2

P: n/a
Dear Peter,

I am working on Speech To Text Recognition System that uses IBM Via Voice
SRE.
I am passing wave file as input to API function conatined in AUDMME.DLL
I think this DLL is written in C.

When I gives the file e.g.("D:\Hello$#Word$\hello.wav") as input to API
function of AUDMME.DLL, it gives error as "Unable to open input wave file".

If I change the file path as "D:\HelloWord\hello.wav", it works perfectly.

It means that above API function, which converts Wave file into text needs
file path which should not include special characters like in DOS file.

So to convert Win32 file path into DOS file path, I used following API,
which returns me valid DOS file path for given file, and then I pass the
converted DOS file path to AUDMME.DLL.which wordks correctly.

----------------------------------------------------------------------------
-----------------------------
API to convert WIN NTFS file path to DOS FAT file path
----------------------------------------------------------------------------
-----------------------------
Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath
As String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal cchBuffer
As Integer) As Integer
----------------------------------------------------------------------------
-----------------------------

Now another problem is that, when folder name is less than 8 characters and
if it contains one or more special characters then it could not convert into
DOS file path.And in turns doesn't work in AUDMME.DLL function call.

So, my question is how to convert WIN NTFS file path ("D:\Hello$\hello.wav")
into DOS FAT file path.

Thanks and regards,
Sakharam Phapale
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP14.phx.gbl...
What is exactly you want to do, because maybe you don't need the api.

Greetz Peter

"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am using an API function, which takes file path as an input.
When file path contains special characters (@,#,$,%,&,^, etc), API function
gives an error as "Unable to open input file".
Same file path containing special characters works fine in one machine,

but
doesn't work in other.
I am using following API function to get short file path.

Declare Auto Function GetShortPathName Lib "kernel32" (ByVal

lpszLongPath As
String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal
cchBuffer As
Integer) As Integer
Using this I get expected result for most of the time. Bu still in some
combinations I get error. e.g. when file is in "D:\Bin$\hello.wav"

Please, can anyone give me some details about this problem and how to

solve
it.

Thanks in Advance.

Sakharam Phapale


Nov 21 '05 #3

P: n/a
Hi Sakharam,

from what I understand the GetShortPathName API returns the short pathname
for example: c:\Program Files\My Folders will return c:\Progra~1\MyFold~1
but it won't convert c:\bin$* to c:\bin, it just converts the full path to a
path with maximum 8 characters. So you'll have to convert the filename
yourself because the IBM API doesn't accept the special chars, maybe there's
a function to delete special chars from a path but I don't think so

hth Peter
"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
Dear Peter,

I am working on Speech To Text Recognition System that uses IBM Via Voice
SRE.
I am passing wave file as input to API function conatined in AUDMME.DLL
I think this DLL is written in C.

When I gives the file e.g.("D:\Hello$#Word$\hello.wav") as input to API
function of AUDMME.DLL, it gives error as "Unable to open input wave file".
If I change the file path as "D:\HelloWord\hello.wav", it works perfectly.

It means that above API function, which converts Wave file into text needs
file path which should not include special characters like in DOS file.

So to convert Win32 file path into DOS file path, I used following API,
which returns me valid DOS file path for given file, and then I pass the
converted DOS file path to AUDMME.DLL.which wordks correctly.

-------------------------------------------------------------------------- -- -----------------------------
API to convert WIN NTFS file path to DOS FAT file path
-------------------------------------------------------------------------- -- -----------------------------
Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath
As String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal cchBuffer As Integer) As Integer
-------------------------------------------------------------------------- -- -----------------------------

Now another problem is that, when folder name is less than 8 characters and if it contains one or more special characters then it could not convert into DOS file path.And in turns doesn't work in AUDMME.DLL function call.

So, my question is how to convert WIN NTFS file path ("D:\Hello$\hello.wav") into DOS FAT file path.

Thanks and regards,
Sakharam Phapale
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP14.phx.gbl...
What is exactly you want to do, because maybe you don't need the api.

Greetz Peter

"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am using an API function, which takes file path as an input.
When file path contains special characters (@,#,$,%,&,^, etc), API

function
gives an error as "Unable to open input file".
Same file path containing special characters works fine in one machine,
but
doesn't work in other.
I am using following API function to get short file path.

Declare Auto Function GetShortPathName Lib "kernel32" (ByVal

lpszLongPath
As
String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal

cchBuffer
As
Integer) As Integer
Using this I get expected result for most of the time. Bu still in

some combinations I get error. e.g. when file is in "D:\Bin$\hello.wav"

Please, can anyone give me some details about this problem and how to

solve
it.

Thanks in Advance.

Sakharam Phapale



Nov 21 '05 #4

P: n/a
Hi Peter,

Thanks for your kind information.

There is also one thing, when there is a space before special character and
alphabetic character after it e.g. "C:\Hello $Word\hello.wav", --- it works
fine.
"C:\Hello $\hello.wav" --- doesn't work

I am don't understand the standards for it.
Do you know any document or link that would give me any idea of such
standard?

Thanks and Regards,
Sakharam Phapale
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Sakharam,

from what I understand the GetShortPathName API returns the short pathname
for example: c:\Program Files\My Folders will return c:\Progra~1\MyFold~1
but it won't convert c:\bin$* to c:\bin, it just converts the full path to a path with maximum 8 characters. So you'll have to convert the filename
yourself because the IBM API doesn't accept the special chars, maybe there's a function to delete special chars from a path but I don't think so

hth Peter
"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
Dear Peter,

I am working on Speech To Text Recognition System that uses IBM Via Voice
SRE.
I am passing wave file as input to API function conatined in AUDMME.DLL
I think this DLL is written in C.

When I gives the file e.g.("D:\Hello$#Word$\hello.wav") as input to API
function of AUDMME.DLL, it gives error as "Unable to open input wave

file".

If I change the file path as "D:\HelloWord\hello.wav", it works perfectly.
It means that above API function, which converts Wave file into text needs file path which should not include special characters like in DOS file.

So to convert Win32 file path into DOS file path, I used following API,
which returns me valid DOS file path for given file, and then I pass the
converted DOS file path to AUDMME.DLL.which wordks correctly.


--------------------------------------------------------------------------
--
-----------------------------
API to convert WIN NTFS file path to DOS FAT file path


--------------------------------------------------------------------------
--
-----------------------------
Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal

cchBuffer
As Integer) As Integer


--------------------------------------------------------------------------
--
-----------------------------

Now another problem is that, when folder name is less than 8 characters

and
if it contains one or more special characters then it could not convert

into
DOS file path.And in turns doesn't work in AUDMME.DLL function call.

So, my question is how to convert WIN NTFS file path

("D:\Hello$\hello.wav")
into DOS FAT file path.

Thanks and regards,
Sakharam Phapale
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP14.phx.gbl...
What is exactly you want to do, because maybe you don't need the api.

Greetz Peter

"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl...
> Hi All,
>
> I am using an API function, which takes file path as an input.
> When file path contains special characters (@,#,$,%,&,^, etc), API
function
> gives an error as "Unable to open input file".
> Same file path containing special characters works fine in one

machine, but
> doesn't work in other.
> I am using following API function to get short file path.
>
> Declare Auto Function GetShortPathName Lib "kernel32" (ByVal

lpszLongPath
As
> String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal

cchBuffer
As
> Integer) As Integer
> Using this I get expected result for most of the time. Bu still in some > combinations I get error. e.g. when file is in "D:\Bin$\hello.wav"
>
> Please, can anyone give me some details about this problem and how to solve
> it.
>
> Thanks in Advance.
>
> Sakharam Phapale
>
>



Nov 21 '05 #5

P: n/a
Hi Sakharam,

this is a link to GetShortPathName api decalration

http://msdn.microsoft.com/library/de...us/fileio/base
/getshortpathname.asp

I also tested the GetShortPathName API at my pc and with me for example
"c:\test $\test.txt" returns c:\TEST$~1\test.txt so here it does work, if
you mean that the IBM API doesn't accept C:\Hello $\hello.wav I can't help
you with that, accept for suggesting to use filenames without special
characters ;-)

greetz Peter

"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:eT**************@TK2MSFTNGP11.phx.gbl...
Hi Peter,

Thanks for your kind information.

There is also one thing, when there is a space before special character and alphabetic character after it e.g. "C:\Hello $Word\hello.wav", --- it works fine.
"C:\Hello $\hello.wav" --- doesn't work

I am don't understand the standards for it.
Do you know any document or link that would give me any idea of such
standard?

Thanks and Regards,
Sakharam Phapale
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Sakharam,

from what I understand the GetShortPathName API returns the short pathname
for example: c:\Program Files\My Folders will return c:\Progra~1\MyFold~1 but it won't convert c:\bin$* to c:\bin, it just converts the full path to
a
path with maximum 8 characters. So you'll have to convert the filename
yourself because the IBM API doesn't accept the special chars, maybe

there's
a function to delete special chars from a path but I don't think so

hth Peter
"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
Dear Peter,

I am working on Speech To Text Recognition System that uses IBM Via

Voice SRE.
I am passing wave file as input to API function conatined in AUDMME.DLL I think this DLL is written in C.

When I gives the file e.g.("D:\Hello$#Word$\hello.wav") as input to API function of AUDMME.DLL, it gives error as "Unable to open input wave

file".

If I change the file path as "D:\HelloWord\hello.wav", it works perfectly.
It means that above API function, which converts Wave file into text needs file path which should not include special characters like in DOS file.
So to convert Win32 file path into DOS file path, I used following API, which returns me valid DOS file path for given file, and then I pass the converted DOS file path to AUDMME.DLL.which wordks correctly.


--------------------------------------------------------------------------
--
-----------------------------
API to convert WIN NTFS file path to DOS FAT file path


--------------------------------------------------------------------------
--
-----------------------------
Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal

cchBuffer
As Integer) As Integer


--------------------------------------------------------------------------
--
-----------------------------

Now another problem is that, when folder name is less than 8 characters and
if it contains one or more special characters then it could not
convert
into
DOS file path.And in turns doesn't work in AUDMME.DLL function call.

So, my question is how to convert WIN NTFS file path

("D:\Hello$\hello.wav")
into DOS FAT file path.

Thanks and regards,
Sakharam Phapale
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP14.phx.gbl...
> What is exactly you want to do, because maybe you don't need the

api. >
> Greetz Peter
>
> "Sakharam Phapale" <sp******@annetsite.com> wrote in message
> news:#U**************@TK2MSFTNGP10.phx.gbl...
> > Hi All,
> >
> > I am using an API function, which takes file path as an input.
> > When file path contains special characters (@,#,$,%,&,^, etc), API
> function
> > gives an error as "Unable to open input file".
> > Same file path containing special characters works fine in one

machine,
> but
> > doesn't work in other.
> > I am using following API function to get short file path.
> >
> > Declare Auto Function GetShortPathName Lib "kernel32" (ByVal
lpszLongPath
> As
> > String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal
cchBuffer
> As
> > Integer) As Integer
> > Using this I get expected result for most of the time. Bu still in

some
> > combinations I get error. e.g. when file is in "D:\Bin$\hello.wav"
> >
> > Please, can anyone give me some details about this problem and how

to > solve
> > it.
> >
> > Thanks in Advance.
> >
> > Sakharam Phapale
> >
> >
>
>



Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.