FAQ/ListReports.md
... ...
@@ -54,7 +54,7 @@ In [[Database Mode|http://wiki.izenda.us/FAQ/Storing-Reports#Database-Mode]], yo
54 54
55 55
```csharp
56 56
public override ReportInfo[] ListReports() {
57
- ArrayList reportNames = new ArrayList();
57
+ ArrayList reports = new ArrayList();
58 58
59 59
if (AdHocSettings.ReportsPath != null) {
60 60
DirectoryInfo dir = new DirectoryInfo(AdHocSettings.ReportsPath);
... ...
@@ -83,15 +83,13 @@ public override ReportInfo[] ListReports() {
83 83
string fileName = Path.GetFullPath(file.FullName);
84 84
string reportName = fileName.Substring(dirName.Length + (dirName.EndsWith("\\") ? 0 : 1));
85 85
reportName = StringHelper.TrimEnd(reportName, ".xml");
86
- reportNames.Add(new ReportInfo(reportName, readOnly, file.CreationTime,
86
+ reports.Add(new ReportInfo(reportName, readOnly, file.CreationTime,
87 87
file.LastWriteTime));
88 88
}
89 89
}//end foreach
90 90
}//end if
91 91
}//end if
92
- string[] reportNamesArray = new string[reportNames.Count];
93
- reportNames.CopyTo(reportNamesArray, 0);
94
- return (ReportInfo[])reportNames.ToArray(typeof(ReportInfo));
92
+ return (ReportInfo[])reports.ToArray();
95 93
}//end method
96 94
97 95
private static void GetAllXmlFiles(System.IO.DirectoryInfo dir, ArrayList files)
... ...
@@ -150,7 +148,7 @@ End Class
150 148
'BEGIN Filesystem Mode Code Sample
151 149
152 150
Public Overrides Function ListReports() As ReportInfo()
153
- Dim reportNames As New ArrayList()
151
+ Dim reports As New ArrayList()
154 152
155 153
If AdHocSettings.ReportsPath IsNot Nothing Then
156 154
Dim dir As DirectoryInfo = New DirectoryInfo(AdHocSettings.ReportsPath)
... ...
@@ -177,18 +175,16 @@ Public Overrides Function ListReports() As ReportInfo()
177 175
Dim fileName As String = Path.GetFullPath(file.FullName)
178 176
Dim reportName As String = fileName.Substring(dirName.Length + CStr(IIf((dirName.EndsWith("\\"), 0, 1))))
179 177
reportName = StringHelper.TrimEnd(reportName, ".xml")
180
- reportNames.Add(New ReportInfo(reportName, readOnly, file.CreationTime, _
178
+ reports.Add(New ReportInfo(reportName, readOnly, file.CreationTime, _
181 179
file.LastWriteTime))
182 180
End If
183 181
Next
184 182
End If
185 183
End If
186
- Dim reportNamesArray As New String(reportNames.Count)
187
- reportNames.CopyTo(reportNamesArray, 0)
188
- Return (ReportInfo[])reportNames.ToArray(typeof(ReportInfo))
184
+ Return DirectCast(reports.ToArray(), ReportInfo());
189 185
End Function
190 186
191
-Private Shared Sub GetAllXmlFiles(ByVal dir As System.IO.DirectoryInfo, ByVal files As ArrayList)
187
+Private Shared Sub GetAllXmlFiles(ByVal dir As System.IO.DirectoryInfo, ByRef files As ArrayList)
192 188
Try
193 189
files.AddRange(dir.GetFiles("*.xml"))
194 190
Dim subDirs As System.IO.DirectoryInfo[] = dir.GetDirectories()