The code I use is below. If I create a FileStream at Module level and then
call it from one of these callback routines, I get the "File is in use by
another process" exception. My workaround is to call the file routines from
the callbacks, create the FileStream in each routine and then close the
file. I do this on each write as I receive data. How can I do this without
constantly creating/opening and closing the FileStream?
Sub DataConnectedCallBack(ByVal ar As IAsyncResult)
ftpd.EndConnect(ar)
'Create the file
CreateFile()
ftpd.BeginReceive(bufd, 0, bufd.Length, SocketFlags.None, AddressOf
DataReceiveCallBack, bufd)
If QuietMode = False Then Console.WriteLine("Connected to the data
channel." & vbCrLf)
End Sub
Sub DataReceiveCallBack(ByVal ar As IAsyncResult)
bufd = CType(ar.AsyncState, Byte())
Dim numbytes As Int32
numbytes = ftpd.EndReceive(ar)
RcvdByteCount += numbytes
If QuietMode = False Then Console.WriteLine(RcvdByteCount & " bytes
received")
If numbytes = 0 Then
'Close the data channel
ftpd.Close()
If QuietMode = False Then Console.WriteLine("Done with data
file" & vbCrLf)
Exit Sub
End If
'Write the bytes to the file
AppendFile(numbytes)
'Start receiving again...
ftpd.BeginReceive(bufd, 0, bufd.Length, SocketFlags.None, AddressOf
DataReceiveCallBack, bufd)
End Sub
Sub CreateFile()
Dim fs As New FileStream(OutputFile, FileMode.Create)
fs.Close()
End Sub
Sub AppendFile(ByVal numbytes As Integer)
Dim fs As New FileStream(OutputFile, FileMode.Append)
fs.Write(bufd, 0, numbytes)
fs.Close()
End Sub 0 873 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: JustSomeGuy |
last post by:
I have a routine that evaluates a polynomial equation that have 3 variables
x,y,z of orders 1,2,3 the coefficients of the polynomial are in an array.
This routine is quite slow and I'd like to...
|
by: News |
last post by:
Folks,
I need help with this task. I have a set of data that needs to be plotted on
timeline chart.
Example:
Unit ProcStart ProcEnd Machine
U1 5/5/03 6:01 5/5/03 6:04 M1
U2 ...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: P2P |
last post by:
Hi
I am wondering if someone know of a free cross-browsers vertical
scrolling script that
- is cross cross-browsers
- will call the scrolling content from an external html page or from a...
|
by: Sebastian Spandauer |
last post by:
Hey,
i am searching for a php script that features sending a lets say 20
lesson online course.
it should:
subscription on website
opt-in after subsriciption
send one lesson per day to every...
|
by: juan brown |
last post by:
I am new to usenet, need help on how to use it.
|
by: Bart Van der Donck |
last post by:
Hello,
I'm presenting my new library 'AJAX Cross Domain' - a javascript
extension that allows to perform cross-domain AJAX requests.
http://www.ajax-cross-domain.com/
Any comments or...
|
by: ampo |
last post by:
Hello.
Can anyone help with cross-domain problem?
I have HTML page from server1 that send xmlHTTPRequest to server2.
How can I do it?
Thanks.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |