Results 1 to 4 of 4

Thread: [RESOLVED] Problem of setting a file attribute

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2008
    Posts
    26

    Resolved [RESOLVED] Problem of setting a file attribute

    How to set a file attribute that filename consist of UNICODE character?
    for example:

    C:\我的文件.txt

    I've tried SetAttr and SetFileAttributesA(API) are having error.

    Anyone got an idea for unicode filename?

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Problem of setting a file attribute

    Use the wide version: SetFileAttributesW.

    See http://vb.mvps.org/tips/varptr.asp for a tip on using StrPtr() to make this possible from VB6.

  3. #3
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Problem of setting a file attribute

    Unicode aware SetFileAttr
    Returns True if successful


    Code:
    'Purpose: Unicode aware SetFileAttr
    Public Function SetFileAttributes(ByVal lpFilename As String, ByVal dwFileAttributes As Long) As Boolean
       If Len(lpFilename) Then
          SetFileAttributes = SetFileAttributesW(StrPtr(lpFilename), dwFileAttributes) <> 0
       End If
    End Function

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2008
    Posts
    26

    Re: Problem of setting a file attribute

    Thanks for DrUnicode and dilettante, the problem is solved!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width