473,387 Members | 1,529 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,387 software developers and data experts.

Relative Filename Problem

Hi:

I have a problem regarding filenames in Visual C++.

I would like to read from files using relative filenames instead of
absolute filenames. I have tried using the following

fname = .\\<data directory>>\\<<file1>>

I have no problem when executing from within the IDE (i.e. pressing
CTRL+F5) but when I run the executable (i.e. <prog.exe> ), the file
cannot be found.

When I tried to change it to
fname = ../<data directory>>/<<file1>>
the executable can work but this time round, executing from the IDE
will render file not found problem.

I know this may be trivial to experts here but sincerely appreciate
any help. Thank you.
Jul 22 '05 #1
1 1639
On 28 Dec 2003 07:50:10 -0800, ko*****@yahoo.com (Tanuki) wrote in
comp.lang.c++:
Hi:

I have a problem regarding filenames in Visual C++.
Then you need to ask about it in a group that supports your
implementation, such as news:comp.os.ms-windows.win32.programmer or
one of Microsoft's support groups in the news:microsoft.public.vc.*
family.
I would like to read from files using relative filenames instead of
absolute filenames. I have tried using the following

fname = .\\<data directory>>\\<<file1>>

I have no problem when executing from within the IDE (i.e. pressing
CTRL+F5) but when I run the executable (i.e. <prog.exe> ), the file
cannot be found.

When I tried to change it to
fname = ../<data directory>>/<<file1>>
the executable can work but this time round, executing from the IDE
will render file not found problem.

I know this may be trivial to experts here but sincerely appreciate
any help. Thank you.


The C++ language defines file access functions that accept a C style
string for dealing with fstream and FILE * streams. It does not
specify the content of those strings, or how they are interpreted by
the implementation's file system.

The details of how Windows maps strings into paths and file names is a
Windows specific detail, not one specified by the language.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: jason | last post by:
Can anyone help me find a solution to quickly working out relative paths to a folder in the root of my server... Although it easy when you go - say - two levels down: .../includes it...
1
by: Shannon | last post by:
Hi, all -- this is a weird question that does not really have to do with javascript, but I used to spend a lot of time here, and am hoping someone might be able to help... I am trying to...
3
by: Sir Loin of Beef | last post by:
I have a root directory with 1 subdirectory(myphoto), and 2 files. Inside the myphoto subdirectory, I have 1 html page and another image. Root dir: <myphoto> 01.jpg watermark.php myphoto:
1
by: draco | last post by:
Hi, Let's say I have a dynamic library libapple.so with a method applemethod() which expects a filename string. I call this method from main() which is in the file foo.c. Now foo.c and apple.so...
7
by: Rizaan Jappie | last post by:
is it possible to get the relative path based on a absolute path in c#? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
0
by: Lauchlan M | last post by:
Hi In my aspx page HTML I have <a href='<%# DataBinder.Eval(Container.DataItem, "Name") %>'> <%# DataBinder.Eval(Container.DataItem, "Name") %> I am trying to create a hyperlink to...
19
by: Jerry M. Gartner | last post by:
Greetings: What is the best way to resolve paths within a document regardless of what path it is opened under? For example: I have x.php and it contains <img src="images...">, (amongst other...
4
by: DG | last post by:
Alright, I have searched and searched and read many conversations on the topic of relative and absolute imports and am still not getting the whole thing through my skull. Highlights of what I've...
2
by: Peted | last post by:
Hi i have a circumstance where a user unzips a file, with a certain layer of directories to get to a textfile. So in any directory on the HDD they may end up with something like ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.