473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to find existing directory/file within a given path???

I'm working with crystal reports in my windows app.
I have a pre-existing report that I will access dynamically in the application at run time.

I set the parameters of the report through the code, then set the report viewer's source as the report itself after setting the parameters.

But I'm not sure of the best way to go about getting the report FILE after the application is deployed.

The report file is located in the "Reports" directory of my application.

At runtime, I call this method to get the application path:
Application.Info.DirectoryPath

Which gives me the directory that the .exe is located in.
The "Reports" directory a couple of levels higher than that, and this is the directory that the file is located in.

How do I get to that directory without having to hardcode the path after stripping 2-3 levels off the end?

Thanks
Dec 11 '07 #1
5 1442
Shashi Sadasivan
1,435 Expert 1GB
Use the DirectoryInfo to get the directories(folders) contained inside the given folde path.

However to navigate into the folder inside this you would have to hardcode (something similar to XMl, if you dont know the node name, how do you expect to get the value of it)

You should have a good exception handling system which will detect any change in the structure if it has been changed by the user!
Dec 11 '07 #2
no, i need the directories upward in the chain, not within the directory of the application .exe
i need to go backward through the path to the "Reports" directory

i.e. c:\ProgramFiles\MyApp\bin\Release would be my application .exe directory.
the "Reports" directory is located in the "MyApp" directory.
i'm trying to get there.
Dec 11 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
This is not really a good idea to do so.

reason is that when you install it on a machine the baseDirectoy would be something like c:\programFiles\MyProgramCompany\MyProgram
if the user changes the installation path to something like d:\SomeProgram
then you would face issues going backwards because you cannot control the directory structure backwards.

To answer your question

If you are using the DirectoryInfo Class, use the Parent property of the class to go one step behind in the directory !
Dec 12 '07 #4
This is not really a good idea to do so.
I see what you mean in your example.
What would be a more efficient way of doing this then?
I've seen in a few different examples of Crystal Report rendering that they simply use the string of the path to the report file itself within the directory heiarchy, so I was attempting to use that practice.
Dec 13 '07 #5
Never mind, I went with the actual object route instead of dealing with the physical class path.

Thanks for your help though.
Dec 13 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
6
by: Joe Cosby | last post by:
This seems like a simple thing, but I can't find anything in the "Perl Cookbook" or the online Perl docs to answer this. When a script runs from my host's server, the working directory doesn't...
3
by: comp.lang.php | last post by:
Using Linux/PHP 4.3.2 CLI: $fileID = fopen('myfile.txt', 'r'); // WORKS JUST FINE Using Linux/PHP 4.3.8 CLI: $fileID = fopen('myfile.txt'); // THROWS WARNING 'no such file or directory...
8
by: James Owens | last post by:
I'm a relative newbie, interested in storing the information from several server directories and subdirectories in XML so that I can present it selectively using XSL (all files updated today or...
2
by: Dave | last post by:
I have an existing asp page that I would like to upgrade/convert to aspx. It gets a million or two hits per day, so I'm surmising that at a minimum I would benefit from compilation and the...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
8
by: inFocus | last post by:
Hello, I am new to python and wanted to write something for myself where after inputing two words it would search entire drive and when finding both names in files name would either copy or move...
0
by: nimjerry | last post by:
i am using db2 udb V 9 on aix 5.3 and in db2diag.log alwas has this error occurr below is sample message 2008-03-03-09.45.34.366406+420 I306667A443 LEVEL: Warning PID : 835622 ...
3
by: jmark | last post by:
I am currently running php 4.4.7 in windows xp and apache 2. If I enter php in command line. I get the following error The application has failed to start because php5ts.dll was not found" I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.