Re: Rename a unicode file
Sounds like a corrupt hard drive. I saw the same thing last week. All files in Program Files were ??????.??
Re: Rename a unicode file
Thannk you for the concern, however my drive is not corrupted. I am using VB 6 sp6 and need to rename these items, open and inspect them, and then delete them programatically.
Re: Rename a unicode file
the filename being all ?s does sound like the filename table has been corrupted for these files at least. Have you ran a check disk on it?
Re: Rename a unicode file
You say you have captured the name to a variable...
Have you captured the "????????.???" or have you captured the real unicode string somehow?
How do you rename? Using Name... As... ?
I could imagine a little loop using the filesystem object, walking through all the files, showing the names to ask for renaming.
When you use the File object, renaming goes like this:
File.Name = "NewName.xxx"
This should overwrite the name, no matter what it is like.
The ???? are only substitutes for the characters, the OS cannot display.
So you can't Name "???????.???" As "NewName.xxx"
Re: Rename a unicode file
You HD is not corrupted.
VB6 cannot handle unicode correctly, e.g. if you have a filename with japanese characters, they will be displayed in a VB6 program as ?????
You have to use a winapi function, I think it is CopyFileApiW to copy and to rename files:
Declare Function CopyFileApiW Lib "kernel32" Alias "CopyFileW" ( _
ByVal lpExistingFileName As Long, _
ByVal lpNewFileName As Long, _
ByVal bFailIfExists As Long) _
As Long
retval = CopyFileApiW(StrPtr(source), StrPtr(StrConv(Dest), 0)
Re: Rename a unicode file
Normally, you cannot create a folder / file with a Question mark in it on any Windows OS. You get the Question marks because the file name is basically "unknown" / "uniterpretable" by Windows. So, neither Windows nor the Fie system is corrupt :)
If you had known the origin of the file, I could've advised installing a language pack.
Re: Rename a unicode file
Open with a Hex Editor to see what it is. It can't be valid. I'd guess that the file allocation table was written or failed
Re: Rename a unicode file
About all the '?' you're seeing - that's most likely because you don't have a font installed on your system that contains the glyphs for those Unicode characters.
Run this on the command line: "cmd /U /C dir /S > files.txt"
The resulting files.txt will be Unicode encoded. See if Word/WordPad/Notepad can render the glyphs. If not, search for some free CJK fonts that you can install then try again.
gg
Re: Rename a unicode file
Read this thread. I knew that I saw it before. Just found it.
http://www.codeguru.com/forum/showthread.php?t=376680
Re: Rename a unicode file
To all, Thank you for your input.
The file is not all "?", just a couple of the characters. I tried Name xxx As yyy and as one of you stated, it did not work. I will try the CopyFileW API and get back to you tomorrow. Have to get to work.
Re: Rename a unicode file
I read the article Dglienna recommended and it was some help. I finally accomplished what I needed by:
1. Creating a unique file name in memory
2. Using MoveFileW to rename the file or folder
If the process failed, I used DeleteFileW to remove the questionable item.
Consider this resolved and thank you for your input.