Read unicode filenames and put it into a URL

I'm not very experienced with the multilingual/unicode aspects of Windows... so I'm not sure where to begin here.

I have a folder with a number of files in them. Some of the files have unicode names... some contain chinese characters and russian characters, etc.

So what I need to do is read in these file names into a string, such that I preserve the unicode values. Dir() is woefully inadequate for that ;) I think FindFirstFileW() can do it... but I haven't had any luck getting it to work and I feel like there ought to be a managed .NET way of doing this.

The next thing I need to do is pass this unicode string to a webpage, as a parameter in the URL. I don't need code to actually PERFORM the query to the website, I know how to do that. But I don't know how to format the url to include unicode characters. What kind of string would I need to pass as the url? Some kind of unicode string? Or do you convert the unicode characters into some kind of %U12423 type formatting?

I'm looking to do this in VB... whether it is VB.NET or VB6 all depends on which way would be simpler ;) I get the feeling this has already been done nicely in VB.NET I just don't know where it is.
LVL 31
Frosty555Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Göran AnderssonCommented:
> whether it is VB.NET or VB6 all depends on which way would be simpler

Definitely VB.NET. String in .NET are always unicode, and there are classes for decoding a lot of different encodings.

Check if the System.IO.Directory.GetFile method gives you the correct file names. It would surprise me a bit if it didn't.

To encode the names to put them in an url, you use the System.Web.HttpUtility.UrlEncode method.

Example:
Dim files As String() = Directory.GetFiles("c:\somefolder")
Dim url As String = "http://www.somepage.com/somepage.aspx?file=" & HttpUtility.UrlEncode(files(0))

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Frosty555Author Commented:
Yep perfect that worked well!

I knew it couldn't have been that hard ;)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.