Click here to Skip to main content
15,887,344 members
Home / Discussions / C#
   

C#

 
GeneralRe: Euros and decimal.Parse Pin
Simon_uk10-Sep-03 22:34
Simon_uk10-Sep-03 22:34 
GeneralRe: Euros and decimal.Parse Pin
Member 9611-Sep-03 18:30
Member 9611-Sep-03 18:30 
GeneralStandardPrinter Pin
gecko2310-Sep-03 3:14
gecko2310-Sep-03 3:14 
GeneralUsing ODBC databases Pin
Emilio Guijarro10-Sep-03 3:10
Emilio Guijarro10-Sep-03 3:10 
GeneralRe: Using ODBC databases Pin
joan_fl10-Sep-03 4:19
joan_fl10-Sep-03 4:19 
GeneralRe: Using ODBC databases Pin
Emilio Guijarro10-Sep-03 5:31
Emilio Guijarro10-Sep-03 5:31 
GeneralRe: Using ODBC databases Pin
David Stone10-Sep-03 5:37
sitebuilderDavid Stone10-Sep-03 5:37 
GeneralHelp: Object reference not set to an instance of an object. Pin
gros194410-Sep-03 1:30
gros194410-Sep-03 1:30 
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.downProgress.Text = (player.network.downloadProgress).ToString() + " %";

form.currentFR.Text = (player.network.frameRate).ToString() + " FPS";
if(cf.currFR)
{
fs.swFR.WriteLine(player.network.frameRate.ToString() + " " + player.controls.currentPositionString);
}

form.encodFR.Text = (player.network.encodedFrameRate).ToString() + " FPS";
form.framesSkip.Text = (player.network.framesSkipped).ToString();
form.lostPackets.Text = (player.network.lostPackets).ToString();
form.rxQuality.Text = (player.network.receptionQuality).ToString();
form.sourceProtocol.Text = (player.network.sourceProtocol);
form.rxPackets.Text = (player.network.receivedPackets).ToString();
form.recoveredPackets.Text = (player.network.recoveredPackets).ToString();
form.maxBW.Text = (player.network.maxBandwidth).ToString() + " Bps";
fs.swStats.WriteLine("prova");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
//escriure la resta d'estadístiques
try
{
fs.swStats.WriteLine("prova 2"); <--------
fs.swBR.WriteLine("prova");
fs.swStats.WriteLine("prova 3");
fs.swBW.WriteLine("prova");
fs.swStats.WriteLine("Buffering Count: ");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Console.WriteLine(e.Message);
}

fs.Close();
}
}

public class FileStruct
{
public FileStream fileBW;
public StreamWriter swBW;
public FileStream fileBR;
public StreamWriter swBR;
public FileStream fileFR;
public StreamWriter swFR;
public FileStream fileStats;
public StreamWriter swStats;

public void Close()
{
try
{
swBW.Close();
swBR.Close();
swFR.Close();
swStats.Close();
fileBW.Close();
fileBR.Close();
fileFR.Close();
fileStats.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}

The problem is that when arrives to "fs.swStats.WriteLine("prova 2");" it gets the "object reference..." exception, and I can't write anything to the output file....I really don't know what to do!!! Frown | :(

Please, if anyone has any idea, I'd be really grateful!!!! Sigh | :sigh:
GeneralRe: Help: Object reference not set to an instance of an object. Pin
Julian Bucknall [MSFT]10-Sep-03 5:07
Julian Bucknall [MSFT]10-Sep-03 5:07 
GeneralRe: Help: Object reference not set to an instance of an object. Pin
gros194412-Sep-03 1:16
gros194412-Sep-03 1:16 
QuestionBook: C# Unleashed - Any good ? Pin
Stone Free10-Sep-03 0:33
Stone Free10-Sep-03 0:33 
AnswerRe: Book: C# Unleashed - Any good ? Pin
Mazdak10-Sep-03 2:40
Mazdak10-Sep-03 2:40 
GeneralRe: Book: C# Unleashed - Any good ? Pin
Stone Free10-Sep-03 3:07
Stone Free10-Sep-03 3:07 
GeneralRe: Book: C# Unleashed - Any good ? Pin
Mazdak10-Sep-03 5:34
Mazdak10-Sep-03 5:34 
GeneralPlease, help me! Pin
Giant Penguin10-Sep-03 0:20
Giant Penguin10-Sep-03 0:20 
GeneralContextMenu problem Pin
Mazdak9-Sep-03 23:28
Mazdak9-Sep-03 23:28 
GeneralRe: ContextMenu problem Pin
James T. Johnson10-Sep-03 8:25
James T. Johnson10-Sep-03 8:25 
GeneralRe: ContextMenu problem Pin
Mazdak10-Sep-03 9:08
Mazdak10-Sep-03 9:08 
GeneralRe: ContextMenu problem Pin
James T. Johnson10-Sep-03 9:24
James T. Johnson10-Sep-03 9:24 
GeneralRe: ContextMenu problem Pin
Mazdak10-Sep-03 22:00
Mazdak10-Sep-03 22:00 
GeneralAdd typed DataTable from one DataSet to another DataSet Pin
STW9-Sep-03 21:36
STW9-Sep-03 21:36 
GeneralRe: Add typed DataTable from one DataSet to another DataSet Pin
A.Wegierski10-Sep-03 2:54
A.Wegierski10-Sep-03 2:54 
GeneralRelocating Generated Dlls Pin
jtmtv189-Sep-03 13:41
jtmtv189-Sep-03 13:41 
Generalcasting System.Drawing.Imaging.EncoderValue Pin
RHamilton9-Sep-03 12:54
RHamilton9-Sep-03 12:54 
GeneralRetraction: casting System.Drawing.Imaging.EncoderValue Pin
RHamilton10-Sep-03 2:23
RHamilton10-Sep-03 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.