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

S

Sakharam Phapale

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
 
G

Guest

Why are you using this function?
If you have this:
string path = "c:\\folder1\forder2\file.exe"
Extract the short path by:
string ShortPath = path.Substring(s.LastIndexOf("\\" + 1));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top