I found code that returns virtual from local path:
Code:
private string GetImageURL(string strImageFilePath)
{
// Request.Url.GetLeftPart(UriPartial.Authority) yields
// "http://{domain name}"
// Request.ApplicationPath yields "/{virtual directory}"
string imagePath;
imagePath = Request.Url.GetLeftPart(UriPartial.Authority) +
@"/Rosary" + Request.ApplicationPath + @"/traditional/" +
strImageFilePath.Substring(m_strImageDirectory.Length + 1);
return imagePath;
}
with this function I can pass in the string of the path that's in the array like this:
Code:
m_arrImageNames = Directory.GetFiles(m_strImageDirectory);
for(int i = 1;i < m_arrImageNames.Length;++i)
{
myImages[i] = GetImageURL(m_arrImageNames[i]);
}
DataGrid2.DataSource = myImages;
DataGrid2.DataBind();
But then I get this error on line 52:
myImages[i] = GetImageURL(m_arrImageNames[i]);
Code:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 50: for(int i = 1;i < m_arrImageNames.Length;++i)
Line 51: {
Line 52: myImages[i] = GetImageURL(m_arrImageNames[i]);
Line 53:
Line 54: }
I have myImages defined like so:
private string[] myImages;
I tried changing string[] to object[] but it didn't like that either -
what am i doing wrong?