By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

The process cannot access the file because it is being used by another process

nightangel
P: 1
Hi dude,what i was done in my application is uploading a image file to my server using FTP, it work great when pushing a file into the server path using FTP.
The problem i met now is i need to do a resuming for the file uploading if the client connection or server connection is down.

E.g: Sunset.jpg (500KB) when i upload until half of it, (332KB in the server) and unplug my connection, it will looping and try to connect to the server, after i plug back, the FTP login is success, but it throw me an exception, say that: Sunset.jpg "The process cannot access the file because it is being used by another process".

How can i solve the problem? how do i close the file opening in the server?

Expand|Select|Wrap|Line Numbers
  1. SendCommand("STOR " & Path.GetFileName(sFileName))
  2.  
  3. ' Send a command to the FTP Server.
  4. Private Sub SendCommand(ByVal sCommand As String)
  5.         sCommand = sCommand & ControlChars.CrLf
  6.         Dim cmdbytes As Byte() = ASCII.GetBytes(sCommand)
  7.  
  8.         m_objClientSocket.Send(cmdbytes, cmdbytes.Length, 0)
  9.  
  10.         ReadReply()
  11. End Sub
  12.  
  13.  ' Read the reply from the FTP Server
  14. Private Sub ReadReply()
  15.         m_sMes = ""
  16.         m_sReply = ReadLine()
  17.         m_iRetValue = Int32.Parse(m_sReply.Substring(0, 3))
  18. End Sub
  19.  
  20. ' Read a line from the server.
  21. Private Function ReadLine() As String
  22.  
  23.         Dim seperator As Char = ControlChars.Lf
  24.         Dim mess() As String
  25.  
  26.         If (bClearMes) Then
  27.             m_sMes = ""
  28.         End If
  29.         Do While (True)
  30.             Array.Clear(m_aBuffer, 0, BLOCK_SIZE)
  31.             m_iBytes = m_objClientSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
  32.             m_sMes += ASCII.GetString(m_aBuffer, 0, m_iBytes)
  33.  
When the program is reading the line from the server, it replying a message from " m_sMes " : Sunset.jpg "The process cannot access the file because it is being used by another process".
Apr 20 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.