472,342 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

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

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
5 8445
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve....
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to...
14
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file...
8
by: sore eyes | last post by:
Hi I just downloaded the free Watcom compiler and am having a little trouble with File IO http://www.openwatcom.org/index.php/Download I...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: ...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.