473,890 Members | 1,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 GetShortPathNam e Lib "kernel32" (ByVal lpszLongPath As
String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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 8640
What is exactly you want to do, because maybe you don't need the api.

Greetz Peter

"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:#U******** ******@TK2MSFTN GP10.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 GetShortPathNam e Lib "kernel32" (ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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.wa v") 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\h ello.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.whic h wordks correctly.

----------------------------------------------------------------------------
-----------------------------
API to convert WIN NTFS file path to DOS FAT file path
----------------------------------------------------------------------------
-----------------------------
Declare Auto Function GetShortPathNam e Lib "kernel32" (ByVal lpszLongPath
As String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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$\hel lo.wav")
into DOS FAT file path.

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

Greetz Peter

"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:#U******** ******@TK2MSFTN GP10.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 GetShortPathNam e Lib "kernel32" (ByVal

lpszLongPath As
String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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 GetShortPathNam e API returns the short pathname
for example: c:\Program Files\My Folders will return c:\Progra~1\MyF old~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******@annet site.com> wrote in message
news:O0******** ******@tk2msftn gp13.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.wa v") 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\h ello.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.whic h wordks correctly.

-------------------------------------------------------------------------- -- -----------------------------
API to convert WIN NTFS file path to DOS FAT file path
-------------------------------------------------------------------------- -- -----------------------------
Declare Auto Function GetShortPathNam e Lib "kernel32" (ByVal lpszLongPath
As String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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$\hel lo.wav") into DOS FAT file path.

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

Greetz Peter

"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:#U******** ******@TK2MSFTN GP10.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 GetShortPathNam e Lib "kernel32" (ByVal

lpszLongPath
As
String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi Sakharam,

from what I understand the GetShortPathNam e API returns the short pathname
for example: c:\Program Files\My Folders will return c:\Progra~1\MyF old~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******@annet site.com> wrote in message
news:O0******** ******@tk2msftn gp13.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.wa v") 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\h ello.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.whic h wordks correctly.


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


--------------------------------------------------------------------------
--
-----------------------------
Declare Auto Function GetShortPathNam e Lib "kernel32" (ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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$\hel lo.wav")
into DOS FAT file path.

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

Greetz Peter

"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:#U******** ******@TK2MSFTN GP10.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 GetShortPathNam e Lib "kernel32" (ByVal

lpszLongPath
As
> String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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 GetShortPathNam e api decalration

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

I also tested the GetShortPathNam e 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******@annet site.com> wrote in message
news:eT******** ******@TK2MSFTN GP11.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******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi Sakharam,

from what I understand the GetShortPathNam e API returns the short pathname
for example: c:\Program Files\My Folders will return c:\Progra~1\MyF old~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******@annet site.com> wrote in message
news:O0******** ******@tk2msftn gp13.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.wa v") 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\h ello.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.whic h wordks correctly.


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


--------------------------------------------------------------------------
--
-----------------------------
Declare Auto Function GetShortPathNam e Lib "kernel32" (ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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$\hel lo.wav")
into DOS FAT file path.

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

api. >
> Greetz Peter
>
> "Sakharam Phapale" <sp******@annet site.com> wrote in message
> news:#U******** ******@TK2MSFTN GP10.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 GetShortPathNam e Lib "kernel32" (ByVal
lpszLongPath
> As
> > String, ByVal lpszShortPath As System.Text.Str ingBuilder, 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
2029
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". 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
0
3952
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. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
1
5431
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 completely/succsessfully on the client's computer before updating some metadata on the server (file downloaded date for instance) However, All examples i have tried, and all examples I have found that other people says works - doesn't work for me :-(
8
3729
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 and save it to a file. This step is not to hard however the contents of the textarea is mostly latex source so it contains just about every special character you can imagine. My question is this, how do I save an exact copy of the textarea...
1
6528
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" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
14
2827
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 by df -k lopgod10:~/mycrfile # df -k /mnt/mvdg1/vset Filesystem 1K-blocks Used Available Use% Mounted on
8
2041
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 Command line arguments so that I could debug more easily. The example is a simple file copy. and it works. but I would like to customize this to automate some redundant changes in some large files.
1
64294
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 article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
34
5388
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 "<pyshell#10>", line 1, in <module> os.startfile("C:\Documents and Settings\Alex\My Documents\My
0
9978
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11227
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10922
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9630
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7169
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4676
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.