SmbException while trying to read from SmbFileInputStream

Almog <[email protected]>
Newsgroups gmane.network.samba.java
Message-ID <[email protected]>
Hi,

I am trying to read a file which exists on a remote machine using JCIFS 1.3.17 
using the following code:


   {
      long               fileSize                  = 0;
      long               tmpFileSize               = logFile.getLastFileSize();
      SmbFile            tmpsmbFile                = logFile.getSmbFile();
      SmbFileInputStream tmpsmbInputStream         = new 
SmbFileInputStream(tmpsmbFile);
      long               smbFileLength             = tmpsmbFile.length();
      long               l_Count                   = 0L;
      int                ch                        = 0;
      long               skipCount                 = 0L;
      Reader tmpreader = null;
      BufferedReader tmpbufferedReader = null;


		  if (tmpFileSize != 0 && tmpFileSize < smbFileLength)
		  {
		     fileSize = logFile.getLastFileSizeInChar();
		     skipCount = tmpsmbInputStream.skip(tmpFileSize);
		  }
		  else
		  {
		     fileSize = 0;
		  }
		  tmpreader = new InputStreamReader(tmpsmbInputStream, 
charset_);
		  tmpbufferedReader = new BufferedReader(tmpreader);
		  
		  while ((ch = tmpbufferedReader.read()) > -1)
		  {
		     l_Count++;
		  }


		  fileSize += l_Count;
		  logFile.setLastFileSizeInChar(fileSize);
		  tmpbufferedReader.close();
		  tmpreader.close();
		  tmpsmbInputStream.close();
		  logFile.setLastFileSize(smbFileLength);

      return fileSize;

   }
   

occasionally, one of the commands fails, and throws an SmbException with the 
error: "The handle is invalid".
sometimes the exception is thrown from the read() method, and sometimes from the 
skip() method.

is there something i'm doing wrong?

Thanks,
Almog.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.