Using '\' as the lead character in the "Save As" dialog

G

Guest

I recently found out about a bug in my company's product that I can reproduce
in other software. Launch an application (try it with Notepad) and perform
"Save As". Enter any legal name in the "File name" field, but before you hit
"Save" insert the character \ as the first character in the "File name"
field. No matter what folder the "Save As" dialog is displaying, if you
insert the \ symbol the file will be named in the root folder.

So if you are expecting to save "Receipt.txt" as:
C:\Documents and Settings\username\My Documents\Receipt.txt

But type "\Receipt.txt" in the file name field, your file will be created as:
C:\Receipt.txt


So is this a bug, or is this a feature? I can see this as being a quick way
to save a file to the root, but Microsoft seems to be discouraging the
practice of saving things to the root of the C drive. So why would they
create a way to make it easy to do just that?
 
T

Tom Porterfield

Steve said:
I recently found out about a bug in my company's product that I can reproduce
in other software. Launch an application (try it with Notepad) and perform
"Save As". Enter any legal name in the "File name" field, but before you hit
"Save" insert the character \ as the first character in the "File name"
field. No matter what folder the "Save As" dialog is displaying, if you
insert the \ symbol the file will be named in the root folder.

So if you are expecting to save "Receipt.txt" as:
C:\Documents and Settings\username\My Documents\Receipt.txt

But type "\Receipt.txt" in the file name field, your file will be created as:
C:\Receipt.txt


So is this a bug, or is this a feature? I can see this as being a quick way
to save a file to the root, but Microsoft seems to be discouraging the
practice of saving things to the root of the C drive. So why would they
create a way to make it easy to do just that?

They didn't create this, it's how the underlying file system works.
Open a command prompt window by running cmd.exe in the Start->Run box.
The path in the command prompt window should default to your profile
directory under Documents and Settings. Now use the chdir command to
change to a different directory, passing it just \. Ex:

chdir \
or
cd \

You will notice that the command prompt path is now in the root of the
drive. What you have stumbled across is behavior of the underlying file
system navigation that has been there since it was created. Go back to
early versions of DOS and the behavior is the same.
--
Tom Porterfield
MS-MVP Windows
http://support.telop.org

Please post all follow-ups to the newsgroup only.
 
P

Pegasus \(MVP\)

Steve said:
I recently found out about a bug in my company's product that I can reproduce
in other software. Launch an application (try it with Notepad) and perform
"Save As". Enter any legal name in the "File name" field, but before you hit
"Save" insert the character \ as the first character in the "File name"
field. No matter what folder the "Save As" dialog is displaying, if you
insert the \ symbol the file will be named in the root folder.

So if you are expecting to save "Receipt.txt" as:
C:\Documents and Settings\username\My Documents\Receipt.txt

But type "\Receipt.txt" in the file name field, your file will be created as:
C:\Receipt.txt


So is this a bug, or is this a feature? I can see this as being a quick way
to save a file to the root, but Microsoft seems to be discouraging the
practice of saving things to the root of the C drive. So why would they
create a way to make it easy to do just that?

It's not a bug at all. By adding a backslash, you override the default
location and give explicit instructions to Windows where you wish the
file to be saved.
 
B

bumtracks

I use that all the time with \path\filename.txt quicker, but mostly
because my finger too often forgets where the :::colon::: is and types L.
 
G

Guest

It's not a bug at all. By adding a backslash, you override the default
location and give explicit instructions to Windows where you wish the
file to be saved.

This is very interesting. Thanks for explaining it because I never knew it
worked this way.

Thanks!
 
Y

Yves Leclerc

This is not a bug! This has been around since the MS DOS day. You are
specifing the "absolute" pathname in the filename. "\" is the reserved name
for the main root folder of the current drive.
 
S

Stan Brown

I recently found out about a bug in my company's product that I can reproduce
in other software. Launch an application (try it with Notepad) and perform
"Save As". Enter any legal name in the "File name" field, but before you hit
"Save" insert the character \ as the first character in the "File name"
field. No matter what folder the "Save As" dialog is displaying, if you
insert the \ symbol the file will be named in the root folder.

How is that a bug? A filename beginning with \ is supposed to be in
the root folder of the current drive.

I'll grant you that it may be surprising to someone who's not
thinking about it, but I don't see how it's a bug.
 
G

Ghostrider

Yves said:
This is not a bug! This has been around since the MS DOS day. You are
specifing the "absolute" pathname in the filename. "\" is the reserved name
for the main root folder of the current drive.

There are still those of us who know how to live by the
command prompt and then there are those newbies who had
their brains turned to mush by the GUI (or "gooey").
<:-}}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top