Thank you very much!! I think I've found the problem, although is not about cf.buffCount. You're right, I'll encapsulate this function into another class, thank you very much! ;)
gros1944
Posts
-
Help: Object reference not set to an instance of an object. -
Help: Object reference not set to an instance of an object.Here's part of my project: public class NetworkStats { private Form1 form; private AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer player; private ConfigResult cf; public NetworkStats(Form1 form1, AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer player1, ConfigResult cf1) { form = form1; player = player1; cf = cf1; } public FileStruct FileStats() { string path; DirectoryInfo dir; FileStruct fs = new FileStruct(); path = cf.pathLog + "\\" + player.currentMedia.name + "\\"; dir = new DirectoryInfo(cf.pathLog); dir.CreateSubdirectory(player.currentMedia.name); if(cf.buffCount) { try { fs.fileStats = new FileStream(path + "Stats.txt", FileMode.Create, FileAccess.Write); fs.swStats = new StreamWriter(fs.fileStats); } catch (Exception e) { Console.WriteLine(e.Message); } } if(cf.currBW) { try { fs.fileBW = new FileStream(path + "currBW.txt", FileMode.Create, FileAccess.Write); fs.swBW = new StreamWriter(fs.fileBW); } catch (Exception e) { Console.WriteLine(e.Message); } } if(cf.currBR) { try { fs.fileBR = new FileStream(path + "currBR.txt", FileMode.Create, FileAccess.Write); fs.swBR = new StreamWriter(fs.fileBR); } catch (Exception e) { Console.WriteLine(e.Message); } } if(cf.currFR) { try { fs.fileFR = new FileStream(path + "currFR.txt", FileMode.Create, FileAccess.Write); fs.swFR = new StreamWriter(fs.fileFR); } catch (Exception e) { Console.WriteLine(e.Message); } } return fs; } public void initStats() { FileStruct fs; fs = FileStats(); while (Form1.videoParat != true) { try { form.BitRate.Text = (player.network.bitRate).ToString() + " Bps"; if(cf.currBR) { fs.swBR.WriteLine(player.network.bitRate.ToString() + " " + player.controls.currentPositionString); } form.BW.Text = (player.network.bandWidth).ToString() + " Bps"; if(cf.currBW) { fs.swBW.WriteLine(player.network.bandWidth.ToString() + " " + player.controls.currentPositionString); } form.buffCount.Text = (player.network.bufferingCount).ToString(); form.buffProgress.Text = (player.network.bufferingProgress).ToString(); form.buffTime.Text = (player.network.bufferingTime).ToString() + " mseg"; form.downPr