473,854 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

long path names for ifstream in(

opening a file
ifstream in("../../../../../../data/ZB/Jun06/20060405");

then on the command line I do
fred@debian:~/myPrograms/cpp/practice/ticpp1/co2/3$ make; ./proj

is there a way to save some typing and cleaner than this.

Jul 20 '06 #1
1 2651
Gary Wessle wrote:
opening a file
ifstream in("../../../../../../data/ZB/Jun06/20060405");

then on the command line I do
fred@debian:~/myPrograms/cpp/practice/ticpp1/co2/3$ make; ./proj

is there a way to save some typing and cleaner than this.
Put the "../.." part in a std::string (or macro, yuck!) and prepend it
to all appropriate file names? Use the absolute path? Put a link to the
data directory in your executable directory? Require that the user run
the executable from a certain location so you can use relative paths?
Etc. etc. etc.

Cheers! --M

Jul 20 '06 #2

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

Similar topics

by: solartimba | last post by:
Why can I open a file using a C-string but not a C++ string? //C-strings works char path; strcpy(path,"c:\test.txt"); ifstream infile(path); //C++ string class does not string path("c:\test.txt"); ifstream infile(path);
by: Arjan van den Noort | last post by:
How to delete a directory (with all containing directories and files) with vb.net if the directory contains long paths ? (just like the dos command: RD /S/Q path) What I want is a routine to delete files and folders from a shared folder (accessed by its UNC-notation). That's all ! Some path names can be long (> 200 characters ) and there are some files and folders that can be read-only. The exceptions I get:
by: Zenu | last post by:
Hi, I have a system with very long paths and I'm trying to use file.exist(Longpath) to test the paths existance but it gives a message that the path is too long. Can someone tell me how to manupulate long path in VB.NET. I am refering to fully qualified paths over 32000 characters where each component of the path could be up to 255 characters.
by: jccorreu | last post by:
I've got to read info from multiple files that will be given to me. I know the format and what the data is. The thing is each time we run the program we may be using a differnt number of files, with different file names each time. So i'm writing into the code to ask the user how many files, and what their names are. From each we'll read in 2 lines, then do some math using all of those lines. Then do it again on another set of lines. ...
by: Ben | last post by:
Hi We have a list of file paths and short file names in our database. We need to loop through them all, picking up the long file name from the file itself and check that the long file name does not include a "~" character. I have the short file name and path in a variable (eg "c:\data\123442~1.doc") how can I get the long file name from this data.
by: Martin Carpella | last post by:
Hi! I know, that Path-names should be shorter than MAX_PATH (250), but the Win32-SDK allows specifiying longer names using the "\\?\" prefix. As I have an application that accesses files directly using the volume name instead of the drive letter (i.e. "\\?\Volume{...}\subdir\file.ext"), I sometimes get an PathTooLongException, as the total string exceeds 260 characters (due to the "\\?\Volume{...}\"-part).
by: pedagani | last post by:
Dear comp.lang.c++, I'm trying to read a file with very long filename using ifstream. Although, the file exists the file open for read fails. Is there a restriction on the size? I'm using winXP with VS2005. Please advice. Thank you.
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
Before you respond with "just use GetShortPathName" please read the rest. We have an application that places files on a file server using mapped drives as it's path of choice. The reason for this is because using a UNC paths makes the path longer, causing the periodic problem with a path that is too long (over 260 chars). We also have an asp.net app that needs to access those files. Accessing mapped drives from an IIS application is...
by: mpalomas | last post by:
Hi C++ folks, I have trouble to open files whose path contains non-ascii characters with std::ifstream. For instance let's say i just have a file which has Japanese characters either in the file path or the file name : 疑問.dat. The file itself does not contains unicode characters or whatever, it is a binary file, but the file name, or path, contains non-ascii characters, here it is Japanese but it could be anything else, i know...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.