I want to write and read file.rdl to make report in wpf c#, but there is an error "Access is denied to the path c:\\Document and Setting\\SipusProv\\Temp\\reportTemp.rdl. This is my source code:
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());
}
}
"Access denied" means exactly what it says. The real questions are
It's no good asking the rest of the world why permissions are as they are on your specific system. Only you are in a position to investigate that.
This "question" gives me a terrible urge to say "plz send me teh configz".
i think u run program under Windows Vista/7 try to use Application Manifest file
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.