TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
blah bleh
NA
4
0
Qustions about filereading
May 29 2007 11:22 AM
Hey I have a small but annoying problem here which i hope i can get an answer for: I'm using a filestream class to read a mp3 file. I want to be able to read the entire file and close it when i reach EOF. this is an output from my class so far: public bool PlayFile() { FileStream readmp3 = new FileStream(tmpfile, FileMode.Open, FileAccess.Read); /* tmpfile is private variable that is initialized in constructor to the constructor param. int pos = 0; //decide position long len = readmp3.Length; hold = @readmp3.Name; //temporary variable for name of file char []sepinfo = new char[]{'/', '\\'}; string []split = hold.Split(sepinfo); int gf_index = split.GetUpperBound(0); hold = split[gf_index]; /* this is the part im unsure if i actually can read the entire filelength in a single bytebuffer? Im not sure it can handle it. Should i create a smaller buffer? (actually got zombie-state exception from mci once, heh) */ byte []filebuffer = new byte[readmp3.length]; try { if (open) //open is a private bool to check if file open { pccmd = "play mediaFile"; //command to mci mciSendString(pccmd, null, 0, IntPtr.Zero); readmp3.read(filebuffer, 0, (long)readmp3.length)); //either this or replace fs-length with filebuffer length. return true; } } catch(System.IO.IOException ioex) { System.Windows.Forms.MessageBox.Show("blah blah"); } return false; } Note: Closing filestream comes after with finally block. If anyone could give me an answer on this, it would be much appreciated. /xorl
Reply
Answers (
2
)
Error: Attempted to read or write protected memory
getting the Process.MainWindowTitle while running the program as a windows service