Я хочу написать и прочитать файл file.rdl, чтобы создать отчет в wpf c #, но есть ошибка «Доступ запрещен к пути c: \ Document and Setting \ SipusProv \ Temp \ reportTemp.rdl. Это мой источниккод:
private void LaporanRdl(string rdl, DataSet data, string judul)
{
DataSet dt = data;
dt.DataSetName= "Data";
Masaddy.Reprot report = new Masaddy.Reprot();
try
{
//System.IO.StreamReader strReader = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\rdl\" + rdl + ".rdl");
System.IO.StreamReader strReader = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\rdl\" + rdl + ".rdl");
string pathTemp = AppDomain.CurrentDomain.BaseDirectory + @"Temp\reportTemp.rdl";
System.IO.StreamWriter strWriter = new System.IO.StreamWriter(pathTemp);
string strIsi = "";
while (strIsi != "</Report>")
{
strIsi = strReader.ReadLine().Trim();
if (strIsi == "<Value>txtDep</Value>")
{
strIsi = " <Value>" + this.ddDeputi.SelectedItem.ToString() + "</Value>";
}
if (strIsi == "<Value>txtDir</Value>")
{
strIsi = " <Value>" + this.ddDir.SelectedItem.ToString() + "</Value>";
}
if (strIsi == "<Value>txtSubDir</Value>")
{
strIsi = " <Value>" + this.ddSubDir.SelectedItem.ToString() + "</Value>";
}
if (strIsi == "<Value>txtTahun</Value>")
{
strIsi = " <Value>" + this.txtTahun.Text.ToString() + "</Value>";
}
strWriter.WriteLine(strIsi);
}
strWriter.Dispose();
Masaddy.ReportForm r = new Masaddy.ReportForm(AppDomain.CurrentDomain.BaseDirectory + @"\\Temp\\reportTemp.rdl", "Data", dt.Tables[0]);
r.Text = judul;
r.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}