473,695 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Microsoft still does not understand file paths. (strDrive & strDirectory & "\" & strFilename is INCORRECT)

I think the .NET framework is great!

It's nice, clean and logical; in contradiction to the old Microsoft.



It only saddens me that the new Microsoft still doesn't under stand there own rules when it comes to file paths.

A lot of Microsoft installers for example, and also installers of other companies, do not work because they handle paths in the following manner:



strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" = "C:\WrongDirect oryWithoutSlash \Filename.ext"

This seems correct...but it is not.

What happened if the directory is the root directory?

Or what if the directory is a correct directory?

Look at the following:



strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" & "Filename.e xt" = "C:\\Filename.e xt"
strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\CorrectDirect oryEndingWithAS lash\" & "\" & "Filename.e xt" = "C:\CorrectDire ctoryEndingWith ASlash\\Filenam e.ext"

The result is a path with double slashes...and therefore wrong...

A directory not ending with a slash is by definition a file.

A file ending with a slash is by definition a directory.

The difference between the directory named "bla" and the file named "bla" is the slash.

That's how programs know the difference. (Copy, "Is the destination a file or a directory?")
Dear Microsoft,



If you do not understand something as simple as file locations...

(You know..."file locations"...th e most important thing...were it all begins...)

....then what must become of you?

Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality (http://docs.msdnaa.net/ark_new3.0/cd...hapter%202.doc)

Yours,

BoonHead, The Lost Philosopher

I'm not that good in putting it into words.

Actualy I'm pretty bad in putting this into words.

But does anyone understand this problem and does anyone agee or disagree with me?

Jul 21 '05 #1
11 3637
Hi Boonhead.
You're wrong about the slash. The difference between a file and a directory
is not the slash. A directory is a file with the directory flag set.

This is how the file system knows. it takes a file, checks the directory
flag, and treats it accordingly.

Have a look at unix file attributes for confirmation of this, you have flags
for Read,Write and Execute permissions for Users,Groups and Others, and a
directory flag. eg rw-r--r--d (please don't pull me up on the suitability of
this permission set btw :o) )

Your problem is passing a directory name with a trailing slash. Well as you
can see, you are labouring under a misapprension, and creating your own
problem.

Can I suggest, that if you need to pass a directory name to a string
formatter that appends its own trailing slash, that you check the string
first for a trailing slash manually and remove it. Not a tricky bit of code:

if Right( strDirectory, 1 ) = "\" Then strDirectory = Left(strDirecto ry,
strDirectory.Le ngth-1 )

hope this helps,

Leon

"BoonHead, The Lost Philosopher" <bo******@savag etiger.org> wrote in message
news:3f******** *************** @news.euronet.n l...
I think the .NET framework is great!
It's nice, clean and logical; in contradiction to the old Microsoft.

It only saddens me that the new Microsoft still doesn't under stand there
own rules when it comes to file paths.
A lot of Microsoft installers for example, and also installers of other
companies, do not work because they handle paths in the following manner:

strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" =
"C:\WrongDirect oryWithoutSlash \Filename.ext"

This seems correct...but it is not.
What happened if the directory is the root directory?
Or what if the directory is a correct directory?
Look at the following:

strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" &
"Filename.e xt" = "C:\\Filename.e xt"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirect oryEndingWithAS lash\" & "\" & "Filename.e xt" =
"C:\CorrectDire ctoryEndingWith ASlash\\Filenam e.ext"

The result is a path with double slashes...and therefore wrong...
A directory not ending with a slash is by definition a file.
A file ending with a slash is by definition a directory.
The difference between the directory named "bla" and the file named "bla" is
the slash.
That's how programs know the difference. (Copy, "Is the destination a file
or a directory?")

Dear Microsoft,

If you do not understand something as simple as file locations...
(You know..."file locations"...th e most important thing...were it all
begins...)
....then what must become of you?
Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality
(http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft
%20course%20-%20Chapter%202. doc)

Yours,

BoonHead, The Lost Philosopher

I'm not that good in putting it into words.
Actualy I'm pretty bad in putting this into words.
But does anyone understand this problem and does anyone agee or disagree
with me?
Jul 21 '05 #2
Dear Lean,

I usualy have something as this function in my programs:

Function CorrectPath(str Path) As String
'I hope it's just a directory name that has been send as a
parameter...Som etimes you have no way of knowing...
If strPath.Length > 0 Then
Select Case Right(strPath, 1)
Case "\", "/"
Return strPath
Case Else
Return strPath & "/"
End Select
End If
End Function

But that's not the point...

I know how the FAT/DET works but I wasn't refering to the physical part of
files and directories.
I was refering to the textual part; paths.

What if do this?:
C:\>Copy "*.*" "NewName2"
How do you read the directory attribute of a non-existing "object"
(directory or file).
And this is just one lame example...there are better ones.

Unix is a lot better. Unix usualy has nice and correct textual paths.
Hell, I even saw slashes behind every directory name in the file browser in
a Linux distribution once :) ("bin/")

So...
What if the directory/file doesn't exist? What if a path had no physical
object?
Pure textual...Direc tories without a slash are wrong and cause a lot of bugs
if the programmer doesn't incalculate the illogicalness. (And I mean "A LOT
OF BUGS")
Programs and liberaries programmed by a good programmer always have the
standard "try-to-correct-illogicalness"-code which is a waste of bytes and
time.

Yours,

BoonHead

"Leon Jollans" <Le************ **********@xama n.com> wrote in message
news:#6******** ******@TK2MSFTN GP10.phx.gbl...
Hi Boonhead.
You're wrong about the slash. The difference between a file and a directory is not the slash. A directory is a file with the directory flag set.

This is how the file system knows. it takes a file, checks the directory
flag, and treats it accordingly.

Have a look at unix file attributes for confirmation of this, you have flags for Read,Write and Execute permissions for Users,Groups and Others, and a
directory flag. eg rw-r--r--d (please don't pull me up on the suitability of this permission set btw :o) )

Your problem is passing a directory name with a trailing slash. Well as you can see, you are labouring under a misapprension, and creating your own
problem.

Can I suggest, that if you need to pass a directory name to a string
formatter that appends its own trailing slash, that you check the string
first for a trailing slash manually and remove it. Not a tricky bit of code:
if Right( strDirectory, 1 ) = "\" Then strDirectory = Left(strDirecto ry,
strDirectory.Le ngth-1 )

hope this helps,

Leon

"BoonHead, The Lost Philosopher" <bo******@savag etiger.org> wrote in message news:3f******** *************** @news.euronet.n l...
I think the .NET framework is great!
It's nice, clean and logical; in contradiction to the old Microsoft.

It only saddens me that the new Microsoft still doesn't under stand there
own rules when it comes to file paths.
A lot of Microsoft installers for example, and also installers of other
companies, do not work because they handle paths in the following manner:

strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" =
"C:\WrongDirect oryWithoutSlash \Filename.ext"

This seems correct...but it is not.
What happened if the directory is the root directory?
Or what if the directory is a correct directory?
Look at the following:

strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" &
"Filename.e xt" = "C:\\Filename.e xt"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirect oryEndingWithAS lash\" & "\" & "Filename.e xt" =
"C:\CorrectDire ctoryEndingWith ASlash\\Filenam e.ext"

The result is a path with double slashes...and therefore wrong...
A directory not ending with a slash is by definition a file.
A file ending with a slash is by definition a directory.
The difference between the directory named "bla" and the file named "bla" is the slash.
That's how programs know the difference. (Copy, "Is the destination a file
or a directory?")

Dear Microsoft,

If you do not understand something as simple as file locations...
(You know..."file locations"...th e most important thing...were it all
begins...)
...then what must become of you?
Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality
(http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft %20course%20-%20Chapter%202. doc)

Yours,

BoonHead, The Lost Philosopher

I'm not that good in putting it into words.
Actualy I'm pretty bad in putting this into words.
But does anyone understand this problem and does anyone agee or disagree
with me?

Jul 21 '05 #3
BoonHead, The Lost Philosopher <bo******@savag etiger.org> wrote:
What if the directory/file doesn't exist? What if a path had no physical
object?
Then it's neither a regular file nor a directory, is it? Whether it
should be created as a directory or a file is up to the semantics of
the application in question.
Pure textual...Direc tories without a slash are wrong


Care to provide any documentation to "prove" this? It's not the way
I've ever worked - I've just kept a strict distinction between when
things should be files and when they should be directories.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
I'm not sure I follow under which circumstances this is a problem. if it's
bad user input then you'll need to parse it anyway.

The DOS copy command recognises an existing file or directory with no
problem, but if it doesn't exist how could it know whether to create a file
or a directory? There'd have to be some interesting heuristics in place to
achieve it, but besides that you wouldn't want it to second guess you
anyway. There's not much more frustrating than software that decides it
knows what you want without asking you. Admittedly it might be useful to
have a copy -d flag that creates the source string as a directory but XCopy
will reproduce a directory tree if that's what you want.

Ultimately it's a question of semantics. If you're enumerating files, what's
the real cost of checking the directory bit versus looking for a trailing
slash? Or if it's user friendliness you want, dir will tell you if the
file's a directory by writing a big <DIR> next to the name.

If I understand you, you want to ascertain whether a file is a directory in
code based on whether it ends in a slash. Would you have it end in "/R" if
it was read only too? of course not. So I don't see the problem.

Regards,

Leon

"BoonHead, The Lost Philosopher" <bo******@savag etiger.org> wrote in message
news:3f******** *************** @news.euronet.n l...
Dear Lean,

I usualy have something as this function in my programs:

Function CorrectPath(str Path) As String
'I hope it's just a directory name that has been send as a
parameter...Som etimes you have no way of knowing...
If strPath.Length > 0 Then
Select Case Right(strPath, 1)
Case "\", "/"
Return strPath
Case Else
Return strPath & "/"
End Select
End If
End Function

But that's not the point...

I know how the FAT/DET works but I wasn't refering to the physical part of
files and directories.
I was refering to the textual part; paths.

What if do this?:
C:\>Copy "*.*" "NewName2"
How do you read the directory attribute of a non-existing "object"
(directory or file).
And this is just one lame example...there are better ones.

Unix is a lot better. Unix usualy has nice and correct textual paths.
Hell, I even saw slashes behind every directory name in the file browser in a Linux distribution once :) ("bin/")

So...
What if the directory/file doesn't exist? What if a path had no physical
object?
Pure textual...Direc tories without a slash are wrong and cause a lot of bugs if the programmer doesn't incalculate the illogicalness. (And I mean "A LOT OF BUGS")
Programs and liberaries programmed by a good programmer always have the
standard "try-to-correct-illogicalness"-code which is a waste of bytes and
time.

Yours,

BoonHead

"Leon Jollans" <Le************ **********@xama n.com> wrote in message
news:#6******** ******@TK2MSFTN GP10.phx.gbl...
Hi Boonhead.
You're wrong about the slash. The difference between a file and a directory
is not the slash. A directory is a file with the directory flag set.

This is how the file system knows. it takes a file, checks the directory
flag, and treats it accordingly.

Have a look at unix file attributes for confirmation of this, you have

flags
for Read,Write and Execute permissions for Users,Groups and Others, and a directory flag. eg rw-r--r--d (please don't pull me up on the suitability of
this permission set btw :o) )

Your problem is passing a directory name with a trailing slash. Well as you
can see, you are labouring under a misapprension, and creating your own
problem.

Can I suggest, that if you need to pass a directory name to a string
formatter that appends its own trailing slash, that you check the string
first for a trailing slash manually and remove it. Not a tricky bit of

code:

if Right( strDirectory, 1 ) = "\" Then strDirectory = Left(strDirecto ry,
strDirectory.Le ngth-1 )

hope this helps,

Leon

"BoonHead, The Lost Philosopher" <bo******@savag etiger.org> wrote in

message
news:3f******** *************** @news.euronet.n l...
I think the .NET framework is great!
It's nice, clean and logical; in contradiction to the old Microsoft.

It only saddens me that the new Microsoft still doesn't under stand

there own rules when it comes to file paths.
A lot of Microsoft installers for example, and also installers of other
companies, do not work because they handle paths in the following manner:
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" =
"C:\WrongDirect oryWithoutSlash \Filename.ext"

This seems correct...but it is not.
What happened if the directory is the root directory?
Or what if the directory is a correct directory?
Look at the following:

strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" &
"Filename.e xt" = "C:\\Filename.e xt"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirect oryEndingWithAS lash\" & "\" & "Filename.e xt" =
"C:\CorrectDire ctoryEndingWith ASlash\\Filenam e.ext"

The result is a path with double slashes...and therefore wrong...
A directory not ending with a slash is by definition a file.
A file ending with a slash is by definition a directory.
The difference between the directory named "bla" and the file named "bla" is
the slash.
That's how programs know the difference. (Copy, "Is the destination a

file or a directory?")

Dear Microsoft,

If you do not understand something as simple as file locations...
(You know..."file locations"...th e most important thing...were it all
begins...)
...then what must become of you?
Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality

(http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft
%20course%20-%20Chapter%202. doc)

Yours,

BoonHead, The Lost Philosopher

I'm not that good in putting it into words.
Actualy I'm pretty bad in putting this into words.
But does anyone understand this problem and does anyone agee or disagree
with me?


Jul 21 '05 #5
Damn, sorry for misspelling your name Leon.
The DOS copy command recognises an existing file or directory with no
problem, but if it doesn't exist how could it know whether to create a file or a directory? There'd have to be some interesting heuristics in place to
achieve it, but besides that you wouldn't want it to second guess you
anyway. There's not much more frustrating than software that decides it
knows what you want without asking you.
TRUE
Admittedly it might be useful to
have a copy -d flag that creates the source string as a directory but XCopy
will reproduce a directory tree if that's what you want.
But why al the programming fuz and program a -d flag when the slash saids it all?
And why not have a root directory with out an ending slash? (which is also it's starting slash)
(Just like you...I know why not...just a hypo-question...)

Should time-critical components constantly filter each others output?

Let me ask you a question...asid e the issue of correct/incorrect paths...
What do you think of 75% of installers, Microsofts and non-Microsoft, that fail when supplier with a path ending with a slash?

I just think it just doesn't seem consistant.
And that when we are talking about software systems...
Ultimately it's a question of semantics. If you're enumerating files, what's the real cost of checking the directory bit versus looking for a trailing
slash? Or if it's user friendliness you want, dir will tell you if the
file's a directory by writing a big <DIR> next to the name.
A name isn't a path. The Linux file browser example was just related but slashes in the file browser is not nessisary. It just suprised me.
If I understand you, you want to ascertain whether a file is a directory in code based on whether it ends in a slash. Would you have it end in "/R" if
it was read only too? of course not. So I don't see the problem.
Attributes are, in anyway, not part of a path.

"Leon Jollans" <Le************ **********@xama n.com> wrote in message
news:uH******** ******@tk2msftn gp13.phx.gbl... I'm not sure I follow under which circumstances this is a problem. if it's
bad user input then you'll need to parse it anyway.

The DOS copy command recognises an existing file or directory with no
problem, but if it doesn't exist how could it know whether to create a file or a directory? There'd have to be some interesting heuristics in place to
achieve it, but besides that you wouldn't want it to second guess you
anyway. There's not much more frustrating than software that decides it
knows what you want without asking you. Admittedly it might be useful to
have a copy -d flag that creates the source string as a directory but XCopy will reproduce a directory tree if that's what you want.

Ultimately it's a question of semantics. If you're enumerating files, what's the real cost of checking the directory bit versus looking for a trailing
slash? Or if it's user friendliness you want, dir will tell you if the
file's a directory by writing a big <DIR> next to the name.

If I understand you, you want to ascertain whether a file is a directory in code based on whether it ends in a slash. Would you have it end in "/R" if
it was read only too? of course not. So I don't see the problem.

Regards,

Leon

"BoonHead, The Lost Philosopher" <bo******@savag etiger.org> wrote in message news:3f******** *************** @news.euronet.n l...
Dear Lean,

I usualy have something as this function in my programs:

Function CorrectPath(str Path) As String
'I hope it's just a directory name that has been send as a
parameter...Som etimes you have no way of knowing...
If strPath.Length > 0 Then
Select Case Right(strPath, 1)
Case "\", "/"
Return strPath
Case Else
Return strPath & "/"
End Select
End If
End Function

But that's not the point...

I know how the FAT/DET works but I wasn't refering to the physical part of
files and directories.
I was refering to the textual part; paths.

What if do this?:
C:\>Copy "*.*" "NewName2"
How do you read the directory attribute of a non-existing "object"
(directory or file).
And this is just one lame example...there are better ones.

Unix is a lot better. Unix usualy has nice and correct textual paths.
Hell, I even saw slashes behind every directory name in the file browser in
a Linux distribution once :) ("bin/")

So...
What if the directory/file doesn't exist? What if a path had no physical
object?
Pure textual...Direc tories without a slash are wrong and cause a lot of

bugs
if the programmer doesn't incalculate the illogicalness. (And I mean "A

LOT
OF BUGS")
Programs and liberaries programmed by a good programmer always have the
standard "try-to-correct-illogicalness"-code which is a waste of bytes and time.

Yours,

BoonHead

"Leon Jollans" <Le************ **********@xama n.com> wrote in message
news:#6******** ******@TK2MSFTN GP10.phx.gbl...
Hi Boonhead.
You're wrong about the slash. The difference between a file and a

directory
is not the slash. A directory is a file with the directory flag set.

This is how the file system knows. it takes a file, checks the directory flag, and treats it accordingly.

Have a look at unix file attributes for confirmation of this, you have

flags
for Read,Write and Execute permissions for Users,Groups and Others, and a directory flag. eg rw-r--r--d (please don't pull me up on the suitability
of
this permission set btw :o) )

Your problem is passing a directory name with a trailing slash. Well
as you
can see, you are labouring under a misapprension, and creating your

own problem.

Can I suggest, that if you need to pass a directory name to a string
formatter that appends its own trailing slash, that you check the string first for a trailing slash manually and remove it. Not a tricky bit of

code:

if Right( strDirectory, 1 ) = "\" Then strDirectory = Left(strDirecto ry, strDirectory.Le ngth-1 )

hope this helps,

Leon

"BoonHead, The Lost Philosopher" <bo******@savag etiger.org> wrote in

message
news:3f******** *************** @news.euronet.n l...
I think the .NET framework is great!
It's nice, clean and logical; in contradiction to the old Microsoft.

It only saddens me that the new Microsoft still doesn't under stand

there own rules when it comes to file paths.
A lot of Microsoft installers for example, and also installers of other companies, do not work because they handle paths in the following manner:
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" =
"C:\WrongDirect oryWithoutSlash \Filename.ext"

This seems correct...but it is not.
What happened if the directory is the root directory?
Or what if the directory is a correct directory?
Look at the following:

strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" & "Filename.e xt" = "C:\\Filename.e xt"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirect oryEndingWithAS lash\" & "\" & "Filename.e xt" =
"C:\CorrectDire ctoryEndingWith ASlash\\Filenam e.ext"

The result is a path with double slashes...and therefore wrong...
A directory not ending with a slash is by definition a file.
A file ending with a slash is by definition a directory.
The difference between the directory named "bla" and the file named "bla"
is
the slash.
That's how programs know the difference. (Copy, "Is the destination a

file or a directory?")

Dear Microsoft,

If you do not understand something as simple as file locations...
(You know..."file locations"...th e most important thing...were it all
begins...)
...then what must become of you?
Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality

(http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft
%20course%20-%20Chapter%202. doc)

Yours,

BoonHead, The Lost Philosopher

I'm not that good in putting it into words.
Actualy I'm pretty bad in putting this into words.
But does anyone understand this problem and does anyone agee or disagree with me?



Jul 21 '05 #6

Let me ask you a question...asid e the issue of correct/incorrect paths...
What do you think of 75% of installers, Microsofts and non-Microsoft, that fail when supplier with a path ending with a slash?

Don't supply a path ending with a slash then ;o)

Seriously though, isn't that the fault of the installer, rather than Microsoft per sé

Leon

Jul 21 '05 #7
BoonHead,
Have you looked at System.IO.Path. Combine function? Its a .NET class that
applies consistent formatting for paths.

Instead of :

strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" =
"C:\WrongDirect oryWithoutSlash \Filename.ext"

Use:

Imports System.IO

Dim drive As String = "C:"
Dim directory As String = "\WrongDirector yWithoutSlash"
Dim file As String = "Filename.e xt"
Dim path As String

path = Path.Combine(dr ive, directory)
path = Path.Combine(pa th, file)

Which does have an interesting side effect, the drive is dropped as
directory is 'rooted', if you apply:

directory = directory.Trim( Path.DirectoryS eparatorChar,
Path.AltDirecto rySeperatorChar )

Before the first Path.Combine then you have the desired effect. However I
noticed that it creates a relative path to C: not out of the root... Hmm...

Either way I would suggest you use Path.Combine over string concatenation,
as the Path.Combine has set rules for combining paths, where as String
concatenation gives you what you put in.

Hope this helps
Jay

"BoonHead, The Lost Philosopher" <bo******@savag etiger.org> wrote in message
news:3f******** *************** @news.euronet.n l...
I think the .NET framework is great!

It's nice, clean and logical; in contradiction to the old Microsoft.

It only saddens me that the new Microsoft still doesn't under stand there
own rules when it comes to file paths.

A lot of Microsoft installers for example, and also installers of other
companies, do not work because they handle paths in the following manner:

strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" =
"C:\WrongDirect oryWithoutSlash \Filename.ext"

This seems correct...but it is not.

What happened if the directory is the root directory?

Or what if the directory is a correct directory?

Look at the following:

strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" &
"Filename.e xt" = "C:\\Filename.e xt"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirect oryEndingWithAS lash\" & "\" & "Filename.e xt" =
"C:\CorrectDire ctoryEndingWith ASlash\\Filenam e.ext"

The result is a path with double slashes...and therefore wrong...

A directory not ending with a slash is by definition a file.

A file ending with a slash is by definition a directory.

The difference between the directory named "bla" and the file named "bla" is
the slash.

That's how programs know the difference. (Copy, "Is the destination a file
or a directory?")
Dear Microsoft,

If you do not understand something as simple as file locations...

(You know..."file locations"...th e most important thing...were it all
begins...)

....then what must become of you?

Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality
(http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft
%20course%20-%20Chapter%202. doc)

Yours,

BoonHead, The Lost Philosopher

I'm not that good in putting it into words.

Actualy I'm pretty bad in putting this into words.

But does anyone understand this problem and does anyone agee or disagree
with me?
Jul 21 '05 #8
Dear Jay,

Yes, I have seen the path combine function.
Still I would like to thank you for your tip.
(I think this function is better than nothing.)

Yours,

BoonHead.

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message
news:#m******** ******@TK2MSFTN GP11.phx.gbl...
BoonHead,
Have you looked at System.IO.Path. Combine function? Its a .NET class that
applies consistent formatting for paths.

Instead of :

strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" =
"C:\WrongDirect oryWithoutSlash \Filename.ext"

Use:

Imports System.IO

Dim drive As String = "C:"
Dim directory As String = "\WrongDirector yWithoutSlash"
Dim file As String = "Filename.e xt"
Dim path As String

path = Path.Combine(dr ive, directory)
path = Path.Combine(pa th, file)

Which does have an interesting side effect, the drive is dropped as
directory is 'rooted', if you apply:

directory = directory.Trim( Path.DirectoryS eparatorChar,
Path.AltDirecto rySeperatorChar )

Before the first Path.Combine then you have the desired effect. However I
noticed that it creates a relative path to C: not out of the root... Hmm...
Either way I would suggest you use Path.Combine over string concatenation,
as the Path.Combine has set rules for combining paths, where as String
concatenation gives you what you put in.

Hope this helps
Jay

"BoonHead, The Lost Philosopher" <bo******@savag etiger.org> wrote in message news:3f******** *************** @news.euronet.n l...
I think the .NET framework is great!

It's nice, clean and logical; in contradiction to the old Microsoft.

It only saddens me that the new Microsoft still doesn't under stand there
own rules when it comes to file paths.

A lot of Microsoft installers for example, and also installers of other
companies, do not work because they handle paths in the following manner:

strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirector yWithoutSlash" & "\" & "Filename.e xt" =
"C:\WrongDirect oryWithoutSlash \Filename.ext"

This seems correct...but it is not.

What happened if the directory is the root directory?

Or what if the directory is a correct directory?

Look at the following:

strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" &
"Filename.e xt" = "C:\\Filename.e xt"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirect oryEndingWithAS lash\" & "\" & "Filename.e xt" =
"C:\CorrectDire ctoryEndingWith ASlash\\Filenam e.ext"

The result is a path with double slashes...and therefore wrong...

A directory not ending with a slash is by definition a file.

A file ending with a slash is by definition a directory.

The difference between the directory named "bla" and the file named "bla" is the slash.

That's how programs know the difference. (Copy, "Is the destination a file
or a directory?")
Dear Microsoft,

If you do not understand something as simple as file locations...

(You know..."file locations"...th e most important thing...were it all
begins...)

...then what must become of you?

Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality
(http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft %20course%20-%20Chapter%202. doc)

Yours,

BoonHead, The Lost Philosopher

I'm not that good in putting it into words.

Actualy I'm pretty bad in putting this into words.

But does anyone understand this problem and does anyone agee or disagree
with me?

Jul 21 '05 #9
Dear Leon,
Don't supply a path ending with a slash then ;o) I was not refering to me.
Seriously though, isn't that the fault of the installer, rather than Microsoft per sé

I don't understand...Th e installer is Microsoft's...

But okey...Let say that you are right...
(Don't get me wrong: I think you just as easely could be right.)
Let say Directory paths without a slash is normal.

Should we not set a new standard?
Paths ending with a slash is logical.
....no more fuz-code...

"Leon Jollans" <Le************ **********@xama n.com> wrote in message news:#T******** ******@TK2MSFTN GP09.phx.gbl...

Let me ask you a question...asid e the issue of correct/incorrect paths...
What do you think of 75% of installers, Microsofts and non-Microsoft, that fail when supplier with a path ending with a slash?

Don't supply a path ending with a slash then ;o)

Seriously though, isn't that the fault of the installer, rather than Microsoft per sé

Leon
Jul 21 '05 #10

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

Similar topics

0
1413
by: prasat | last post by:
Hi Does anybody work with mouse package for cfd analysis in c++. I would like to decide issues. Please reply --
5
1760
by: Michael Hill | last post by:
I have a general question about how people generally tend to deal with users data that they enter. As an example users enter double quotes in a text field surrounding a specific piece of text they want to hi-lite and then it barfs during the oracle insert step because the string is not properly delimited. Another example is where the ampersand causes trouble when used on an xml page so provisions are made to insert it into the table...
3
4693
by: 21novembre | last post by:
Hi all, I made a question several days before to describe my strange trouble of mysqldump. But I still can't figour it out. Well, I just want to ask another question whether I could just backup my databases by copying the data folder to some place? Then if I meet some disaster, could I just copy the backup folder back to recover my databases? Thank you. Zh.y
2
20518
by: Eric Osman | last post by:
Hi, I'm looking for a javascript function that will convert input such as this: <CLUB Code=" into this: &lt;CLUB Code=&quot;
1
1749
by: Sandy | last post by:
writing a data to open (.txt) notepad file in desktop from vc++... then small rectangle are coming in the file "\n" is also not working int iLength = (int)::SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0); ::SendMessage(hEdit, WM_GETTEXT, iLength+1, (LPARAM)textData); CString temp = textData; temp += "\n"; temp += "MFC"; sprintf(textData,"%s",temp);
5
3434
by: martin | last post by:
Hi, I would be extremly grateful for some help on producing an xml fragemt. The fragment that I wish to produce should look like this <Addresses> <Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address> </Addresses>
11
360
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own rules when it comes to file paths. A lot of Microsoft installers for example, and also installers of other companies, do not work because they handle paths in the following manner:
2
37728
by: jmash | last post by:
Suppose I have the following string whch is part of an xml string: String s= "Script Id=&quot;Test&quot; " And I need to get s= "Script Id="Test" " Can anyone tell me how this can acheived? Thanks, jmash
4
3888
by: fran7 | last post by:
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in &quot;&quot; instead of "" otherwise I get an error message. Can anyone suggest how to write it so that it writes &quot; instead of "". I have tried all combinations of adding &quot; to the code but as soon as I think I am there I get throw out again. if...
0
8555
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9112
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, 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...
0
8817
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5831
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();...
0
4336
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...
0
4571
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2258
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.