[RESOLVED] Object Reference not set to an...
Object Reference Not Set To An Instance Of An Object
Code:
private void SetAudioList()
{
audioList = rtbOrder.Lines;
for (int i = 0; i < audioList.Length; i++)
{
audioRefList[i] = (Application.StartupPath + @"\AudioFiles\" + audioList[i]);
}
}
The line, audioRefList[i] = ....., is the one where the error appears on. audioRefList and audioList are both string[]'s that are declared at the top of the class. rtbOrder is a richtextbox.
EDIT
I solved the problem by adding this line of code:
Code:
audioRefList = new string[rtbOrder.Lines.Length - 1];
The reason i didnt set the array in the first place is because i thought i didn't have the ammount of items it was going to contain.
Re: [RESOLVED] Object Reference not set to an...
If you're targeting .NET 3.5 then you have LINQ at your disposal:
csharp Code:
audioRefList = (from line in rtbOrder.Lines
select string.Format(@"{0}\AudioFiles\{1}",
Application.StartupPath,
line)).ToArray();