Results 1 to 2 of 2

Thread: file system error(1026)

  1. #1
    Guest
    hi
    when using the following api call i get an error which
    reads: cannot delete file
    file system error

    Public Type SHFILEOPSTRUCT
    hwnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAnyOperationsAborted As Long
    hNameMappings As Long
    lpszProgressTitle As Long
    End Type

    Public Declare Function SHFileOperation Lib _
    "shell32.dll" Alias "SHFileOperationA" (lpFileOp _
    As SHFILEOPSTRUCT) As Long

    Public Const FO_DELETE = &H3
    Public Const FOF_ALLOWUNDO = &H40
    'moves file to recycle bin

    code bit

    Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    Select Case Button.Key

    Case "delete"
    Dim SHop As SHFILEOPSTRUCT
    Dim strwav As String

    With SHop
    .wFunc = FO_DELETE
    .pFrom = strwav
    .fFlags = FOF_ALLOWUNDO
    End With

    SHFileOperation SHop
    End Select

    End Sub


    any ideas

  2. #2
    Guest
    Looks like your trying to send files to the Recycle Bin.

    Code:
    Private Declare Function SHFileOperation _
     Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As _
    SHFILEOPSTRUCT) As Long
    
    Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
    "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
    
    Private Const FO_DELETE = &H3
    Private Const FOF_ALLOWUNDO = &H40
    
    Private Type OPENFILENAME
    lStructSize As Long
    HwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
    End Type
    
    Private Type SHFILEOPSTRUCT
        hwnd As Long
        wFunc As Long
        pFrom As String
        pTo As String
        fFlags As Integer
        fAnyOperationsAborted As Long
        hNameMappings As Long
        lpszProgressTitle As Long
    End Type
    
    Sub Recycler(hwnd As Long)
    Dim typOperation As SHFILEOPSTRUCT
    Dim ofn As OPENFILENAME
    Dim button As Long
    ofn.lStructSize = Len(ofn)
    ofn.HwndOwner = hwnd
    ofn.hInstance = App.hInstance
    ofn.lpstrFilter = "*.*"
    ofn.lpstrFile = Space$(254)
    ofn.nMaxFile = 255
    ofn.lpstrFileTitle = Space$(254)
    ofn.nMaxFileTitle = 255
    ofn.lpstrInitialDir = CurDir
    ofn.lpstrTitle = "Choose a file"
    ofn.flags = 0
    Dim lngRetVal As Long
    lngRetVal = GetOpenFileName(ofn)
    If (lngRetVal) Then
        With typOperation
            .wFunc = FO_DELETE
            .pFrom = Trim$(ofn.lpstrFile)
            .fFlags = FOF_ALLOWUNDO
        End With
        SHFileOperation typOperation
    End If
    Exit Sub
    End Sub
    
    Private Sub Command1_Click()
    Call Recycler(hwnd)
    End Sub

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