|
that should not take much code
first use a System.IO.FileSteam(fileName, FileMode, FileAccess, FileShare)
then pass this stream into a System.IO.StreamReader
then use streamReader.ReadLine() to return each line as a String, or there are other options in the stream reader to read from certain offsets, and certain lengths, then whatever data you capture this way can be passed to the MessageBox.Show(message, boxTitle, Buttons, Icon)
|
|
|
|
|
System.File.ReadAllLines("c:\text.log");
will give you a string array, ReadAllText will give a single string.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
That will teach me to read documentationin advance, not just when I'm stuck. How many times in my code do I open a file, called ReadToEnd, or iterate through the file populating my array manually...
Cheers (again!) Christian for that one.
|
|
|
|
|
hello, this is my first question on The Code Project, I am writing a program that can record worship services for my church, then later burn the recorded tracks. I am using XPBurn to burn the CD audio, but my problem is, alot of our tracks flow from one right into the other, so therefore I need to remove the 2 second audio gap, does anyone know a way to do this, or have any other suggestions. I am also not married to the idea of XPBurn, it just seemed the easiest. Also i would like to be able to dynamically set the volume name of the cd before it burns. Both AudioGapSize and VolumeName properties are read only and cannot be set in the XPBurnCD class
thanks in advance for any help anyone can offer
|
|
|
|
|
I need some help... I have a method that I want to execute at a specific time.
For example, every 3PM it will execute this method.
Any suggestions or help on this. I don't think it would be that difficult... I was thinking I could just capture the system time, on form load. Then while (system time == 3PM) execute method.
Not sure if that would work
Let me know asap!
Thanks guys
|
|
|
|
|
i think that use the Timer will match your needs.
|
|
|
|
|
yeah - i'm kind of figuring out how that works.
I created an action for the timer tick below:
<br />
private void tmrClock_Tick(object sender, EventArgs e)<br />
{<br />
if( sender == tmrClock )<br />
{<br />
Invalidate();<br />
}<br />
On Form load, I have the timer interval set to a few thousand milliseconds. Then I start the timer. This is all I have so far.
I'm guessing my method goes in the tmrClock_Tick?
Is that right?
|
|
|
|
|
javamdk wrote: I'm guessing my method goes in the tmrClock_Tick?
Correct. This method is called when the timer fires.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
helloo guys..okie iam creating acode that can draw different shapes(lines, squar,..etc)thats done then save their info in text file ..(like the start point ,end point,..etc)..thats cool too ; BUTT the problem is its writting the last thing i draw ..(if i draw line then squar ..it writes squar twice)
// save the file
string str_Line;
System.IO.FileStream fs = new System.IO.FileStream("c:\\graphics.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
StreamWriter streamWriter=new StreamWriter(fs);
if(drawwhat==1)
{
for(int j=0;j less than arraylist_points.Count;j++)
streamWriter.WriteLine("Line");
start=(Point)arraylist_points[j];
end=(Point)arraylist_points[j+1];
str_Line=start.ToString()+end.ToString();
streamWriter.WriteLine(str_Line);
j++;
}
}
else if(drawwhat==2)
{
for(int j=0;j {
streamWriter.WriteLine("squar");
start=(Point)arraylist_points[j];
end=(Point)arraylist_points[j+1];
str_Line=start.ToString()+end.ToString();
streamWriter.WriteLine(str_Line);
j++;
}
}
streamWriter.Flush();
streamWriter.Close();
fs.Close();
}
//plzz brothers iam stuck !
|
|
|
|
|
mr jets wrote:
for(int j=0;j less than arraylist_points.Count;j++)
streamWriter.WriteLine("Line");
start=(Point)arraylist_points[j];
end=(Point)arraylist_points[j+1];
This obviously writes each point except the first and last twice.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hello my friend..i know it writes each point twice one for idicate the start ..and other indicate the last..but the problem is when i draw 2 shapes like line the squar ..it writes SQUAR WORD TWICE in the text file as:
squar
{X=151,Y=49}{X=281,Y=143}
squar
{X=55,Y=96}{X=157,Y=202}
|
|
|
|
|
Thats because your code looks like this
for(int j=0;j {
streamWriter.WriteLine("squar");
Move the streamWriter.WriteLine("squar"); outside of the for loop
Plus I would be tempted to actually store this information as XML - that way you can process all of the LINE shapes or all of the SQUARE shapes just by a simple xpath query - otherwise you'll be doing a lot of manual string comparisons and conversions when you read the file back in.....
e.g
<br />
<shapes><br />
<shape type="line><br />
<points><br />
<point x="100" y="100" /><br />
<point x="200" y="100" /><br />
<points><br />
</shape><br />
</shapes><br />
-- modified at 2:34 Friday 11th May, 2007
|
|
|
|
|
ok i did that ..:
if(drawwhat==1)
{
streamWriter.WriteLine("Line");
for(int j=0;j lessthan arraylist_points.Count;j++)
{
start=(Point)arraylist_points[j];
end=(Point)arraylist_points[j+1];
str_Line=start.ToString()+end.ToString();
streamWriter.WriteLine(str_Line);
j++;
}
}
else if(drawwhat==2)
{
streamWriter.WriteLine("squar");
for(int j=0;jlessthan arraylist_points.Count;j++)
{
start=(Point)arraylist_points[j];
end=(Point)arraylist_points[j+1];
str_Line=start.ToString()+end.ToString();
streamWriter.WriteLine(str_Line); j++;
}
}
streamWriter.Flush();
streamWriter.Close();
fs.Close();
}
it will be saved in text file as :
squar
{X=131,Y=61}{X=265,Y=143}
{X=68,Y=106}{X=146,Y=196}
or u can recommend me ausfull article talkin about this..thats will be abetter idea..
Regards ;
|
|
|
|
|
A basic rule of the forums is "Don't cross post". You have asked this question in other places as well. Please don't.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi guys,
I'am doing a IT project which is a real time E-Learning environment , therefore we are capturing the Audio,Video and the Screen of the lectures machine and broadcast through the internet.
I can capture the viedo in AVI format,but what I want to do is capture the video in away that I can transer the encoded bits through the internet real time.
There are 2 options as I see,
1.VP3 format
2.we can use c++ since it will be much faster
I would like if you could suggest something feasible and how I can achieve it.
Thank you
Best Regards
Khema
-- modified at 23:38 Thursday 10th May, 2007
|
|
|
|
|
what is VP3 ? Your main problem will be that avi files are huge, C++ isn't going to help. The DirectX stuff you're calling is doing all the hard stuff in C++ already.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
VP3 is a video codec.
VP3 is the world's most efficient, open source video codec to date. With VP3, there are no platform limitations and developers are not required to pay the restrictive license fees that other open source codecs make mandatory.
Regards
khema
|
|
|
|
|
I have this Error: 'Proj.frmMain' does not contain a definition for 'Comm1' can someone help me solve this error ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace Proj
{
public partial class frmMain : Form
{
private string[] tx_data = new string[14];
private string[] rx_data = new string[10];
public int i;
public frmMain()
{
InitializeComponent();
InitializeComports();
}
private void InitializeComports()
{
comboBox1.Items.Clear();
foreach (string s in SerialPort.GetPortNames())
comboBox1.Items.Add(s);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label16_Click(object sender, EventArgs e)
{
}
private void label18_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void txtTxmID1_TextChanged(object sender, EventArgs e)
{
}
private void txtTxmID5_TextChanged(object sender, EventArgs e)
{
}
private void lblRx2_TextChanged(object sender, EventArgs e)
{
}
private void lblRx5_TextChanged(object sender, EventArgs e)
{
}
private void cmdRead_Click(object sender, EventArgs e)
{
SerialPort port1 = new SerialPort((comboBox1.Text), 4800, Parity.None, 8, StopBits.One);
//For i = 1 To 6
// lblRx(i).Caption = rx_data(i + 1)
//Next i
readID;
string OutString = null;
string Instring = null;
int y = 0;
port1.Open();
//If the port is opened...
if (port1.IsOpen)
{
//tx_data(0) = "R"
//tx_data(1) = "I"
//tx_data(2) = "D"
//For i = 0 To 2
// Comm1.Output = tx_data(i)
//Next i
OutString = "RID";
port1.NewLine = OutString;
}
}
private void Comm1_OnComm()
{
SerialPort port1 = new SerialPort((comboBox1.Text), 4800, Parity.None, 8, StopBits.One);
string Instring = null;
for (i = 0; i <= 7; i++)
{
Instring = port1.ReadLine;
if (Instring == "")
{
rx_data[i] = "00";
}
else
{
rx_data[i] = System.Convert.ToString(System.Convert.ToInt32(Instring[0]), 16).ToUpper();
}
}
port1;
for (i = 0; i <= 7; i++)
{
if (rx_data[i].Length < 2)
{
rx_data[i] = "0" + rx_data[i];
}
}
for (i = 1; i <= 6; i++)
{
lblRx[i].Caption = rx_data[i + 1];
}
}
public void Display_SysID()
{
SerialPort port1 = new SerialPort((comboBox1.Text), 4800, Parity.None, 8, StopBits.One);
port1.Open();
//If the port is opened...
if (frmMain.Comm1.PortOpen)
{
//tx_data(0) = "R"
//tx_data(1) = "M"
//tx_data(2) = "g"
//tx_data(3) = Char(5)
//tx_data(4) = Char(7)
//For i = 5 To 11
//tx_data(i) = 0
//Next i
//For i = 5 To 11
//tx_data(11) = tx_data(11) Xor tx_data(i)
//tx_data(i) = Char(tx_data(i))
//Next i
//For i = 0 To 11
// frmMain.Comm1.Output = tx_data(i)
//Next i
frmMain.Comm1.Output = "R" + "M" + "g" + (char)(5) + (char)(7) + '\0' + '\0' + '\0' + '\0' + '\0' + '\0' + '\0';
frmMain.Comm1.PortOpen = false;
}
}
private void Form_Unload(int Cancel)
{
System.Environment.Exit(1);
}
public void writeID(string SysID, string SchID, string DeptID, string BlkID, string LevelID, string ClkID)
{
string OutString = null;
OutString = "";
tx_data[0] = "R";
tx_data[1] = "P";
tx_data[2] = "g";
tx_data[3] =
tx_data[4] =
tx_data[5] =
tx_data[6] =
tx_data[7] =
tx_data[8] =
for (i = 0; i <= 12; i++)
{
OutString = OutString + tx_data[i];
}
open_port;
//If the port is opened...
if (Comm1.PortOpen)
{
Comm1.Output = OutString;
Comm1.PortOpen = false;
}
}
public object cvtHexDec(string txtID)
{
string firstnum = null;
string secnum = null;
int f = 0;
int s = 0;
if (txtID.Length == 2)
{
firstnum = txtID.Substring(0, 1).ToUpper();
secnum = txtID.Substring(1, 1).ToUpper();
}
else
{
firstnum = "0";
secnum = txtID.Substring(0, 1).ToUpper();
}
for (i = 65; i <= 70; i++) // check for A - F (Hex format)
{
if (f == (char)(i))
{
f = (i - 55) * 16;
break;
}
}
for (i = 48; i <= 57; i++) // check for 0 - 9 (Hex format)
{
if (f == (char)(i))
{
f = (i - 48) * 16;
break;
}
}
for (i = 65; i <= 70; i++) // check for A - F (Hex format)
{
if (s == (char)(i))
{
s = i - 55;
break;
}
}
for (i = 48; i <= 57; i++) // check for 0 - 9 (Hex format)
{
if (s == (char)(i))
{
s = i - 48;
break;
}
}
f = f + s; //add the total of firstnum & secnum dec
cvtHexDec = (char)(f); //convert back to char
}
public object cvtHexToDec(string txtID)
{
string firstnum = null;
string secnum = null;
byte f = 0;
byte s = 0;
if (txtID.Length == 2)
{
firstnum = txtID.Substring(0, 1).ToUpper();
secnum = txtID.Substring(1, 1).ToUpper();
}
else
{
f = Convert.ToByte(0);
s = Convert.ToByte(0);
}
if (Convert.ToInt32(firstnum[0]) >= 65)
{
f = Convert.ToByte((firstnum[0]) - 55);
}
else
{
f = Convert.ToByte((firstnum[0]) - 48);
}
f = Convert.ToByte(f * 16);
if (Convert.ToInt32(secnum[0]) >= 65)
{
s = Convert.ToByte((secnum[0]) - 55);
}
else
{
s = Convert.ToByte((secnum[0]) - 48);
}
f = Convert.ToByte(f + s); //add the total of firstnum & secnum dec
return (char)(f); //convert back to char
}
private void cmdWrite_Click(object sender, EventArgs e)
{
writeID(txtTxmID0.Text.ToUpper(), txtTxmID1.Text.ToUpper(), txtTxmID2.Text.ToUpper(), txtTxmID3.Text.ToUpper(), txtTxmID4.Text.ToUpper(), txtTxmID5.Text.ToUpper());
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
|
|
|
|
|
Try here and see if there's anything helpful...
http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport(vs.80).aspx
Hope this solves it for you...
|
|
|
|
|
Sounds to me like Comm1 is not defined on your form. What makes you feel it should be ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi,
how to insert textbox values into datagridview???
pls. reply, ill appreciate it
jing
|
|
|
|
|
Try this:
http://www.thescripts.com/forum/thread247261.html
|
|
|
|
|
|
Hi All,
How to validate or extract values from the following ASP label,
"a href="Browse.aspx?s=cc&v=sc">SavingCreditCard(9) /a" ??
I would like to get that count SavingCreditCard(9) in some variable? i would be glad if nayone could help me out.
-- modified at 20:54 Thursday 10th May, 2007
|
|
|
|
|
u can do that in JS . Say document.getELementByID("ID") then open the watch window and check for options there . innerhtml or childrens or value can give u ur "SavingCreditCard(9)". U have to debug that in JS.
|
|
|
|