473,395 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

FileStream throwing exception

Hi.

I'm doing a class for accessing the Serial port using a file stream.
I open the COM using CreateFile(win32API) and then create the file stream.
However when writting several times I get a System.IO.IOException with "An
attempt was made to move the file pointer before
the beginning of the file"

Any help. How could I avoid it?
Nov 15 '05 #1
2 2250
Hi George,
I think that the best way of using the serial port is using an existen
library, take a look at this article from MSDN magazine, you could also
google in this group for another solution, I know this has been discussed
before.

http://msdn.microsoft.com/msdnmag/is...netserialcomm/

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"George" <ge*********@NOSPANgmx.net> wrote in message
news:Xn************************@130.206.5.54...
Hi.

I'm doing a class for accessing the Serial port using a file stream.
I open the COM using CreateFile(win32API) and then create the file stream.
However when writting several times I get a System.IO.IOException with "An
attempt was made to move the file pointer before
the beginning of the file"

Any help. How could I avoid it?

Nov 15 '05 #2
I have already read it, but it seems to be for asynchronous comunication
and mine is sychronous. I don't know how i could get that library to
work.

BTW I have managed to solve my problem. Now I have openned 2 Filestream,
one from reading and the other for writting. This way it works.

"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT dot.state.fl.us>
wrote in news:O$**************@TK2MSFTNGP12.phx.gbl:
Hi George,
I think that the best way of using the serial port is using an
existen
library, take a look at this article from MSDN magazine, you could
also google in this group for another solution, I know this has been
discussed before.

http://msdn.microsoft.com/msdnmag/is...netserialcomm/

Cheers,


--
Saludos a todos
#
# Contra el canon de los CD's
# que ahora no haya protecciones ni multas
#
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Muki Rapp | last post by:
Hi! In the example below, once the media is full, the FileSteam.WriteByte throws an exception and the code is designed to handle it. However, when the GC is invoked, it calls the Finalize of...
40
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
9
by: ljlevend | last post by:
I have two questions related to FileStreams. 1. Is there any way to determine whether a file has the permissions that are required by a FileStream constructor? For example, given the following...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
1
by: paul.hine | last post by:
Hello, I maintain an application that pulls data from a web service and writes it to an Excel sheet. Originally, the app used OleDb to write the Excel. Exports ran fine except that some text...
2
by: ewingate | last post by:
The following code which is supposed to dynamically create files with incrementing names is throwing an exception due to the inclusion of the DateTime.Now component of the sReportSave string: ...
1
by: usenet | last post by:
I wrote some sample code (see below) for nested exception throwing i.e. my catch blocks are throwing exceptions of their own (for simplicity I used standard exceptions). I am getting some...
0
by: Piotrekk | last post by:
Hi I am downloading file from the server. The problem is described in comments.Here is the code: //input stream using (Stream stream = res.GetResponseStream()) { //Problem is here. When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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...
0
marktang
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.