Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 26th, 2007, 07:33 AM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old May 27th, 2007, 01:18 PM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey

I think i've fixed it now

/xorl






Similar Threads
Thread Thread Starter Forum Replies Last Post
yes or no question grstad Classic ASP Databases 0 April 14th, 2006 04:37 AM
Question... stud123 XSLT 3 April 10th, 2006 09:44 AM
Question Ashwini Classic ASP Databases 3 January 10th, 2006 07:20 AM
a question gorji C++ Programming 2 August 11th, 2003 07:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.