Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 985
  • Last Modified:

Visual Basic error 32

Receiving this error while trying to put file on our unix server. Seems to connect just fine and does a directory change, just errors while trying to put the file.

Any help would be appriciated!
0
campbelc
Asked:
campbelc
  • 2
  • 2
1 Solution
 
Erick37Commented:
What is the exact error message?
How are you connecting to the server?
0
 
campbelcAuthor Commented:
The returned error code is 32. No error text is returned.

The InternetOpen works just fine and returns 13369348.
The InternetConnect works just fine and returns 13369352.
The FtpSetCurrentDirectory works just fine and returns true.
I can easily test any of the above simply by providing invalid values, which as expected result in failure return codes.

The FtpPutFile fails. It returns false, and the last error code is 32 as noted above. No text is returned.

I have multiple examples of VB source code. All work just dandy. All transfer the test file just fine. I have used code from each of these examples in my target program, and the result is always as noted above. I've compared variable contents value-for-value between the working and target programs, variable types and everything else I can think of. Obviously something is different between several working source codes and my target program, but I'm damned if I can find a difference.

Any suggestions would be appreciated. Thanks!
0
 
Erick37Commented:
OK,

Assuming that the error number 32 is derived from calling err.lastDLLerror immediately after the call to FtpPutFile, you can get the text of the error with this function:

Private Declare Function FormatMessage Lib "kernel32" _
      Alias "FormatMessageA" (ByVal dwFlags As Long, _
      lpSource As Any, ByVal dwMessageId As Long, _
      ByVal dwLanguageId As Long, ByVal lpBuffer As String, _
      ByVal nSize As Long, Arguments As Long) As Long
   
Private Const FORMAT_MESSAGE_FROM_SYSTEM As Long = &H1000

'----------------------------------------------------------------------------
Private Function ApiErrorText(ByVal ErrNum As Long) As String
      Dim msg As String
      Dim nRet As Long
   
      msg = Space$(1024)
      nRet = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, _
                           ErrNum, 0&, msg, Len(msg), ByVal 0&)
      If nRet Then
         ApiErrorText = Left$(msg, nRet)
      Else
         ApiErrorText = "Error (" & ErrNum & ") not defined."
      End If
End Function
'----------------------------------------------------------------------------

Plugging in the number 32 results in the text message:
"The process cannot access the file because it is being used by another process."

That's all I have so far... still searching for an answer.
0
 
EDDYKTCommented:
Have you tried this program

http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3BQ175179


May be there is security problem have you tried to connect via just


ftp


run from command prompt?
0
 
campbelcAuthor Commented:
oh. ouch.

That's it, absolutely. The target program hadn't closed the file. Program worked immediately when I explicitly closed the file.

That's why the other sources worked fine, because the program I was developing wasn't running and holding the file open.

Thanks!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now