I have windows file import method and applciation works fine if i click buttons manually but same code fails if i run my application using tools like QTP (Quick Test Professional)
I have highlighted failing line in bold. [ remoteStream.Write(buffer, 0, bytesRead);]
using (FileStream localStream = File.OpenRead(filePath))
{
RemoteFile remoteFile = this.serverComponent.GetUploadFileHandle(filePath);
if (remoteFile == null)
{
stopWatch.Stop();
}
using (RemoteFileStream remoteStream = new RemoteFileStream(remoteFile))
{
long localFileSize = localStream.Length;
long readSoFar = 0;
int bytesRead = 0;
byte[] buffer = new byte[bufferSize];
while ((bytesRead = localStream.Read(buffer, 0, bufferSize)) > 0)
{
remoteStream.Write(buffer, 0, bytesRead);
readSoFar += bytesRead;
progressListener.UpdateFileProgress(firmwareID, readSoFar, localFileSize);
}
}
uploadSuccess = this.server.UploadFileDone(remoteFile);
}
stopWatch.Stop();
progressListener.UpdateFileStatus(firmwareID, uploadSuccess ? FirmwareImportStatus.ImportSuccessful : FirmwareImportStatus.ImportFailed);
}
QTP code which triggers the import. SwfWindow("Swfname:=ImportFWImagesWF").SwfButton("Swfname:=btnNext","text:=Import").Click
I am overriding Stream c# class. and I am ending up having Socket exceptions "System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host"
I am overriding Stream c# class. My class name is RemoteFileStream
Server Code
public override void Write(byte[] buffer, int offset, int count)
{
#region Check Args
if (buffer == null)
{
throw (new ArgumentNullException("The buffer is null"));
}
if (offset < 0 || count < 0)
{
throw (new ArgumentOutOfRangeException("The offset or count is negative."));
}
if (offset + count > buffer.Length)
{
throw (new ArgumentException("The sum of offset and count is larger than the buffer length."));
}
#endregion
_rf.Write(buffer, offset, count);//Exception comes from here
}
NOTE: Exception rises only when I access my application from QTP tool. If I manually run my application there is no issues. Is it because of permission issue? Please help me.