question about filereading
Hey
This is my problem:
I want to be able to read a file from start to end without passing the end to the underlying buffer.
An output from one class:
*************************
private string pccmd; //command for mciSendString
private string tmp; //this holds a temporary string for filestream
private bool open; //checks if file is open
*************************
public bool PlayFile()
{
int pos = 0;
System.IO.FileStream mp3fs = new System.IO.FileStream(tmp, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader readmp3 = new System.IO.BinaryReader(mp3fs, Encoding.Default);
mp3fs.Position = pos;
try
{
if (open)
{
pccmd = "play mediaFile";
mciSendString(pccmd, null, 0, IntPtr.Zero);
/* i want to be able to read from start to EOF. Should i use read() instead and define the bytebuffer to read? Peekchar wouldnt be best method i presume to read because it returns every char availible and perhaps something */
do
{
readmp3.ReadBytes(tmp.Length);
pos++;
} while (readmp3.PeekChar() > -1);
}
//not sure if pos goes thru as it should for EOF.
if (pos == tmp.Length)
{
CloseFile();
}
return true;
}
} catch(System.IO.IOException ioex) {
System.Windows.Forms.MessageBox.Show(ioex.Message) ;
}
return false;
}
If someone could give me an answer, it would be much appriciated.
Best regards
/xorl
|