Вопрос по VB

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by ubuntu, 10 Feb 2010.

  1. ubuntu

    ubuntu New Member

    Joined:
    28 Dec 2009
    Messages:
    35
    Likes Received:
    0
    Reputations:
    0
    If FtpPutFile(rs&, "%AppData%\2.txt", "1.txt", 1, 0) = False Then MsgBox "Ошибка передачи файла!", vbExclamation
    ВЫдаёт Ошибка передачи файла!,из за того что не нахожит %AppData%\2.txt
    кто может подсказать как это сделать?

    если кто то не понял,это кусок отправки файла на фтп.
     
  2. Dosia

    Dosia Member

    Joined:
    5 Jun 2009
    Messages:
    118
    Likes Received:
    81
    Reputations:
    6
    В модуль

    Code:
    Public Declare Function SHGetSpecialFolderLocation _
        Lib "shell32" (ByVal hWnd As Long, _
        ByVal nFolder As Long, ppidl As Long) As Long
    
    Public Declare Function SHGetPathFromIDList _
        Lib "shell32" Alias "SHGetPathFromIDListA" _
        (ByVal Pidl As Long, ByVal pszPath As String) As Long
    
    Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)
        
    Public Const MAX_PATH = 260
    Public Const NOERROR = 0
    Public Const CSIDL_APPDATA = &H1A
    
    Public Function SpecFolder(ByVal lngFolder As Long) As String
    Dim lngPidlFound As Long
    Dim lngFolderFound As Long
    Dim lngPidl As Long
    Dim strPath As String
    
    strPath = Space(MAX_PATH)
    lngPidlFound = SHGetSpecialFolderLocation(0, lngFolder, lngPidl)
    If lngPidlFound = NOERROR Then
        lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
        If lngFolderFound Then
            SpecFolder = Left$(strPath, _
                InStr(1, strPath, vbNullChar) - 1)
        End If
    End If
    CoTaskMemFree lngPidl
    End Function
    
    Пример использования

    Private Sub Form_Load()
    MsgBox SpecFolder(CSIDL_APPDATA), vbInformation, ""
    End Sub
     
Loading...