473,324 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 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 8585
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 function gives an error as "Unable to open input file"....
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 conform to any standard style of coding I have seen....
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 streaming down to the client is saved...
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. I am trying to take the contents of a textarea box...
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 /usr/local/php. However, when I set my "error_reporting"...
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 system is full in percent, like the output given...
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 downloaded the following example, commented out the...
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 programming. FYI Although I have called this...
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: Traceback (most recent call last): File...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.