IOExpection error using Streamreader and FileStream
-
hi, this is exactly my first program, i will be using C#. The device i am using is a usb connected PC digital TV receiver this receiver software actually have a function which measure the signal strength, BER and these data are save into an log file (thus it real time measurement data) once i start the device (start watch TV). I am suppose to use C# to get the real time measurement and convert it into graphic (line chart). I have try to get the data for the log file and display it in the textbox using the following code using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Testing_1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { StreamReader objstream = new StreamReader("c:\\measurement.log"); textBox1.Text = objstream.ReadToEnd(); } but this is the error i got : IOExpection was unhandled the file been use by another program. I also try another method which is directly from the usb port which the device is connected to but i am unable to start working on it coding. i had been looking into example of usb_hib and ICSHARPUSBlib but i was unable to get anything out. Thus please help me, if i am in the right direction (get the data from usb directly?) or do you have any better item on how i should get this done, any code to refer to. thank so much
-
hi, this is exactly my first program, i will be using C#. The device i am using is a usb connected PC digital TV receiver this receiver software actually have a function which measure the signal strength, BER and these data are save into an log file (thus it real time measurement data) once i start the device (start watch TV). I am suppose to use C# to get the real time measurement and convert it into graphic (line chart). I have try to get the data for the log file and display it in the textbox using the following code using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Testing_1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { StreamReader objstream = new StreamReader("c:\\measurement.log"); textBox1.Text = objstream.ReadToEnd(); } but this is the error i got : IOExpection was unhandled the file been use by another program. I also try another method which is directly from the usb port which the device is connected to but i am unable to start working on it coding. i had been looking into example of usb_hib and ICSHARPUSBlib but i was unable to get anything out. Thus please help me, if i am in the right direction (get the data from usb directly?) or do you have any better item on how i should get this done, any code to refer to. thank so much
Re-posting your question is considered rude!
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
hi, this is exactly my first program, i will be using C#. The device i am using is a usb connected PC digital TV receiver this receiver software actually have a function which measure the signal strength, BER and these data are save into an log file (thus it real time measurement data) once i start the device (start watch TV). I am suppose to use C# to get the real time measurement and convert it into graphic (line chart). I have try to get the data for the log file and display it in the textbox using the following code using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Testing_1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { StreamReader objstream = new StreamReader("c:\\measurement.log"); textBox1.Text = objstream.ReadToEnd(); } but this is the error i got : IOExpection was unhandled the file been use by another program. I also try another method which is directly from the usb port which the device is connected to but i am unable to start working on it coding. i had been looking into example of usb_hib and ICSHARPUSBlib but i was unable to get anything out. Thus please help me, if i am in the right direction (get the data from usb directly?) or do you have any better item on how i should get this done, any code to refer to. thank so much
I think the reason for the answer is obvious : "c:\\measurement.log" is being used by another program. Instead of reading the log file and displaying the results, you should directly get data from the usb device.
yefeng_law wrote:
I also try another method which is directly from the usb port which the device is connected to but i am unable to start working on it coding
Why? have a look at the examples and if still can not solve contact the manufacturer of the device for library. Thats the only way I think.
-
Re-posting your question is considered rude!
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111hi Harvey Saayman i repost my question after listening to your advice on reading the following forum (How to use the code project forums[^]), thus i repost my question with the title other could understand more, i am sorry i didnt know this action consider rude. I am just hoping I could be able to get help. yefeng_law
-
hi Harvey Saayman i repost my question after listening to your advice on reading the following forum (How to use the code project forums[^]), thus i repost my question with the title other could understand more, i am sorry i didnt know this action consider rude. I am just hoping I could be able to get help. yefeng_law
yes the subject is better this time, but you can edit the original post, you dont have to make a new one
yefeng_law wrote:
I am just hoping I could be able to get help.
and will get help if someone here is able to help you, your new so its fine... but dont repost a question just to get it back on the first page etc.
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
yes the subject is better this time, but you can edit the original post, you dont have to make a new one
yefeng_law wrote:
I am just hoping I could be able to get help.
and will get help if someone here is able to help you, your new so its fine... but dont repost a question just to get it back on the first page etc.
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111Thank i understand what you mean. Regard yefeng_law
-
Thank i understand what you mean. Regard yefeng_law
cool so has there been any progress with your program?
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
cool so has there been any progress with your program?
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111Sad to say no progress at all. I think i would have to get the data from the usb port but i have problem programming even after looking at the code from some example to be correct i don't even know how to start with it. I think i will be dead drop. Anyway thank,would be nice if you have any recommendation for me.