Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want the path of my application for following code,

Dim Report As New ReportDocument
Report.Load("D:\xxx\xx\x\ Report.rpt")
instead of hard coding the path i need it using code

so i tried following code

filepath = Path.GetDirectoryName(Application.ExecutablePath)
but it is returning path as D:\xxx\xx\x\bin\
I dont want that Bin in my path
so what can i do here?
Posted
Updated 23-May-13 21:07pm
v3

You are doing right thing.
It is returning right path of your application.
Because you are currently developing your application executable file of your application is in 'bin' folder.
But when you will install your app in any system it will return the exact path where it is installed.
 
Share this answer
 
Comments
Am Gayathri 24-May-13 2:42am    
But i need
Report.Load("D:\xxx\xx\x\ Report.rpt")

i couldn't find Report.rpt inside Bin folder. so how can i set the path for report?
Mayur Panchal 24-May-13 2:50am    
But if report is in your project/solution then u can access it directly. you don't need the path for that.
Am Gayathri 24-May-13 2:51am    
How can i do that? How can i access directory?
Mayur Panchal 24-May-13 2:54am    
Refer below link
http://www.codeproject.com/Articles/9781/How-to-Load-and-Display-Crystal-Reports-in-VB-NET
Am Gayathri 24-May-13 3:34am    
Hi Thanks I got solution..
try this
VB
dim fullPath as string = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
dim pathOnly as string = fullPath.SubString(0, fullPath.LastIndexOf("\")) & "\Report.rpt"
Happy Coding!
:)
 
Share this answer
 
Comments
Am Gayathri 24-May-13 3:27am    
Error :Length cannot be less than zero. Parameter name: length
Aarti Meswania 24-May-13 3:31am    
what is string you get in fullpath variable?
Am Gayathri 24-May-13 3:34am    
Hi Thanks I got solution..

Dim path As String = Replace(filepath, "\bin", "\Report\ExibitSummeryReport.rpt")
Aarti Meswania 24-May-13 3:39am    
good congrates! :)
Solution :

Dim path As String = Replace(filepath, "\bin", "\Report\ExibitSummeryReport.rpt")
filepath = Path.GetDirectoryName(Application.ExecutablePath)

Dim Report As New ReportDocument
Report.Load(path)
 
Share this answer
 
using this

VB
Dim Report As New ReportDocument
Dim str as string = string.empty
str = Server.MapPath(Report.rpt)
Report.Load(str)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900