[RESOLVED] [help] how to delete file with unicode filepath
hey guys, i need ur help ...
i've a file named
D:\?-Tö+
i want to delete it, but i didn't yet find how to solve this problem ...
i can't use deletefile() or kill() function ...
please, help me ..
thanks for ur help ..
Re: [help] how to delete file with unicode filepath
Welcome to the forums.
Actually, you can use DeleteFile, but need to use the Unicode version: DeleteFileW
Notice the parameter is different and so is how it is passed
Code:
Private Declare Function DeleteFileW Lib "kernel32.dll" (ByVal lpFileName As Long) As Long
Sample call: lResult = DeleteFileW(StrPtr(sFileName))
sFileName is a string that contains the unicode file name.
Re: [help] how to delete file with unicode filepath
Use the UniCode version of the API
Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileW" (ByVal lpFileName As Long) As Long
Then use stringPointer to point to the file.
DeleteFile strPtr("D:\?-Tö+")
Re: [help] how to delete file with unicode filepath
Quote:
Originally Posted by
some1uk03
Use the UniCode version of the API
Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileW" (ByVal lpFileName As Long) As Long
Then use stringPointer to point to the file.
DeleteFile strPtr("D:\?-Tö+")
thanks 4 the answer guys ... but,
there's no error message for this function, but ... the file is still exist in my D:\ Drive, is there any problem how to write the code ?
actuallly, in windows explorer filename not "?-Tö+", but it's like just a square ...
Re: [help] how to delete file with unicode filepath
How are you getting the file name? I doubt you want to hardcode it. Unless your regional settings are the foreign language, VB's Dir() should not return valid results, neither will a FileListBox. You will want to look at using more APIs to get the file name, depending on how you are getting that name to start with.
You cannot type unicode text into the code window but you can create unicode text in various ways, such as using a byte array then applying StrConv() to that array to return a unicode string that can be passed to unicode version APIs.
Re: [help] how to delete file with unicode filepath
Quote:
Originally Posted by
LaVolpe
How are you getting the file name? I doubt you want to hardcode it. Unless your regional settings are the foreign language, VB's Dir() should not return valid results, neither will a FileListBox. You will want to look at using more APIs to get the file name, depending on how you are getting that name to start with.
You cannot type unicode text into the code window but you can create unicode text in various ways, such as using a byte array then applying StrConv() to that array to return a unicode string that can be passed to unicode version APIs.
i just use 'alt' button and press numeric keyboard,, and so, what should i do now ? to delete the unicode filename ?
Re: [help] how to delete file with unicode filepath
Mozzart....
What LaVolpe is asking is, HOW you are telling VB that the File is there?
Through a list box ? or is it typed in directly in the IDE?
Also that filename doesn't seem to have a file extension! Not that i think is an invalid thing to do, but you might want to make sure the file exists before your use the DeleteFile api.
Re: [help] how to delete file with unicode filepath
Quote:
Originally Posted by
some1uk03
Mozzart....
What LaVolpe is asking is, HOW you are telling VB that the File is there?
Through a list box ? or is it typed in directly in the IDE?
Also that filename doesn't seem to have a file extension! Not that i think is an invalid thing to do, but you might want to make sure the file exists before your use the DeleteFile api.
oh, i'm sorry, my english translate is really bad .. :(
i get the filename from .... common dialog controls ... for the filename that doesn't have any extension, it's ok right ?
Re: [help] how to delete file with unicode filepath
ok.. in that case you should use the CommonDialog APi to be able pass the Unicode Filename, otherwise the default CommonDialog wouldn't return the correct path.
Re: [help] how to delete file with unicode filepath
Quote:
Originally Posted by
some1uk03
ok.. in that case you should use the CommonDialog APi to be able pass the Unicode Filename, otherwise the default CommonDialog wouldn't return the correct path.
okay,, but .. how is it ? can u tell me ?
Re: [help] how to delete file with unicode filepath
You can search this forum and google for more examples. The keywords to search are: unicode & getopenfilename.
Example on this site
Example on another site