|
-
Aug 3rd, 2009, 01:46 PM
#1
Thread Starter
Member
[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 ..
-
Aug 3rd, 2009, 01:54 PM
#2
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.
-
Aug 3rd, 2009, 01:55 PM
#3
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ö+")
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Aug 4th, 2009, 04:15 PM
#4
Thread Starter
Member
Re: [help] how to delete file with unicode filepath
 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 ...
-
Aug 5th, 2009, 08:42 AM
#5
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.
-
Aug 5th, 2009, 02:12 PM
#6
Thread Starter
Member
Re: [help] how to delete file with unicode filepath
 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 ?
-
Aug 5th, 2009, 04:46 PM
#7
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.
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Aug 7th, 2009, 02:09 PM
#8
Thread Starter
Member
Re: [help] how to delete file with unicode filepath
 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 ?
-
Aug 7th, 2009, 03:53 PM
#9
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.
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Aug 7th, 2009, 04:17 PM
#10
Thread Starter
Member
Re: [help] how to delete file with unicode filepath
 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 ?
-
Aug 7th, 2009, 05:57 PM
#11
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|