Spaces in a file path
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?
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.
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.
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).
Hope that helps, sorry if it doesnt (or is a load of BS).
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
Try
system("edit C:\\My\\ Documents\\test.txt");
or
system("edit \"C:\\My Documents\\test.txt\"");
system("edit C:\\My\\ Documents\\test.txt");
or
system("edit \"C:\\My Documents\\test.txt\"");
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement