I am trying open rdlc report but i am getting error below please help
Could not find a part of the path 'E:\Sample_633069\Images~\Images\1.jpg'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'E:\Sample_633069\Images~\Images\1.jpg'.
Source Error:
Line 36: for (int i = 0; i < dsEmployees.Tables["DataTable1"].Rows.Count; i++)
Line 37: {
Line 38: dsEmployees.Tables["DataTable1"].Rows[i]["Image"] = File.ReadAllBytes(Server.MapPath("/Images") + dsEmployees.Tables["DataTable1"].Rows[i]["Path"]);
Line 39: }
Line 40: return dsEmployees;
Source File: e:\Sample_633069\CS.aspx.cs Line: 38
Stack Trace:
[DirectoryNotFoundException: Could not find a part of the path 'E:\Sample_633069\Images~\Images\1.jpg'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +373
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +738
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +68
System.IO.File.InternalReadAllBytes(String path, Boolean checkHost) +84
System.IO.File.ReadAllBytes(String path) +15
CS.GetData(String query) in e:\Sample_633069\CS.aspx.cs:38
CS.Page_Load(Object sender, EventArgs e) in e:\Sample_633069\CS.aspx.cs:15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
System.Web.UI.Control.OnLoad(EventArgs e) +97
System.Web.UI.Control.LoadRecursive() +61
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693
using System;
using System.Configuration;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
using System.IO;
public partial class CS : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
Employees dsEmployees = GetData("SELECT TOP 3 FileId, Name, Path FROM tblfilespath");
ReportDataSource datasource = new ReportDataSource("DataSet1", dsEmployees.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
}
}
private Employees GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlCommand cmd = new SqlCommand(query);
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (Employees dsEmployees = new Employees())
{
sda.Fill(dsEmployees, "DataTable1");
for (int i = 0; i < dsEmployees.Tables["DataTable1"].Rows.Count; i++)
{
dsEmployees.Tables["DataTable1"].Rows[i]["Image"] = File.ReadAllBytes(Server.MapPath("~/") + dsEmployees.Tables["DataTable1"].Rows[i]["Path"]);
}
return dsEmployees;
}
}
}
}
}
My table layout
Name |
Path |
Image |
FileId |
1.jpg |
~/Images/1.jpg |
NULL |
1 |
9.jpg |
~/Images/9.jpg |
NULL |
2 |