Sign in to follow this  
Jareds411

Spaces in a file path

Recommended Posts

Jareds411    108
I have a line of code as such: system("edit C:\\My Documents\\test.txt"); The problem is, it doesn't see the space. How do I get it to use the space between My and Documents?

Share this post


Link to post
Share on other sites
void*    292
well, normally at the command line you could wrap the entire path in quotes, but since you're already inside a string literal, try

system("edit \"C:\\My Documents\\test.txt\"");

if that doesn't work, try escaping the space with '\ ' (not sure if that will work, either)

It's been a long time since I've seen a DOS or Win32 box and/or made system calls on it, but I'm pretty sure the first solution I suggested should work.

Share this post


Link to post
Share on other sites
grekster    640
DOS has a 8.3 limit on name lengths, so I think something like "C:\MY DOC~1\TEST.TXT" should work (cant quite remember though). This is because DOS truncates longer dir names to an 8 charater length (the .3 is for file extensions) and adds ~1 (or ~2, ~3 if theres more than one with the same first 6 characters).

Hope that helps, sorry if it doesnt (or is a load of BS).

Share this post


Link to post
Share on other sites
domstyledesign    100
Quote:
Original post by grekster
DOS has a 8.3 limit on name lengths, so I think something like "C:\MY DOC~1\TEST.TXT" should work (cant quite remember though). This is because DOS truncates longer dir names to an 8 charater length (the .3 is for file extensions) and adds ~1 (or ~2, ~3 if theres more than one with the same first 6 characters).

Hope that helps, sorry if it doesnt (or is a load of BS).


it's all good stuff. the older versions of dos limited file and folder names to 8 chars and no spaces.

so

c:\my documents
could be accessed as
c:\mydocu~1


...oh the nostalgia

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this