FIleInfo.CopyTo to folder with Accented Character in its name

rickey@oware

New member
Joined
Sep 25, 2008
Messages
2
Programming Experience
10+
Hi Experts, Would appreciate if anyone could help me with this problem that I am facing.

I have a folder whose name is: c:\0TEST\David Bollot João Morales

It has an accented ã as you can see.

The following code fails. The error is shown below. It works fine if I replace the ã with any other character, even a japanese unicode character.

VB.NET:
Dim fi As New FileInfo("c:\temp\a1.txt")
fi.CopyTo("c:\0TEST\David Bollot João Morales\newa1.txt", True)

The error generated is:

Could not find a part of the path 'c:\0TEST\David Bollot Jo�o Morales\newa1.txt'.
Callstack: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
at System.IO.FileInfo.CopyTo(String destFileName, Boolean overwrite)


Please help.

Rickey
 
This is a quick fix for you, but I'd recommend looking up special ascii characters

VB.NET:
 Dim mychar As String
        mychar = Convert.ToChar(227)
        Dim teststring As String = "c:\0TEST\David Bollot Jo" & mychar & "o Morales\newa1.txt"
        MsgBox(teststring)

Hope this helps

Redmo
 
Thanks, but, this is just a sample that I posted. I need a more generic solution to the problem. Let's assume that I didn't know the folder name and that it was a variable passed as a string. The folder actually exists, but it has an accented character in its name.

Can you help further?
 
Back
Top