473,396 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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:" & "\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" = "C:\WrongDirectoryWithoutSlash\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.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" = "C:\CorrectDirectoryEndingWithASlash\\Filename.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"...the 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 3567
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(strDirectory,
strDirectory.Length-1 )

hope this helps,

Leon

"BoonHead, The Lost Philosopher" <bo******@savagetiger.org> wrote in message
news:3f***********************@news.euronet.nl...
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:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\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.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" =
"C:\CorrectDirectoryEndingWithASlash\\Filename.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"...the 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(strPath) As String
'I hope it's just a directory name that has been send as a
parameter...Sometimes 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...Directories 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**********************@xaman.com> wrote in message
news:#6**************@TK2MSFTNGP10.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(strDirectory,
strDirectory.Length-1 )

hope this helps,

Leon

"BoonHead, The Lost Philosopher" <bo******@savagetiger.org> wrote in message news:3f***********************@news.euronet.nl...
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:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\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.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" =
"C:\CorrectDirectoryEndingWithASlash\\Filename.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"...the 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******@savagetiger.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...Directories 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.com>
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******@savagetiger.org> wrote in message
news:3f***********************@news.euronet.nl...
Dear Lean,

I usualy have something as this function in my programs:

Function CorrectPath(strPath) As String
'I hope it's just a directory name that has been send as a
parameter...Sometimes 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...Directories 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**********************@xaman.com> wrote in message
news:#6**************@TK2MSFTNGP10.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(strDirectory,
strDirectory.Length-1 )

hope this helps,

Leon

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

message
news:3f***********************@news.euronet.nl...
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:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\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.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" =
"C:\CorrectDirectoryEndingWithASlash\\Filename.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"...the 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...aside 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**********************@xaman.com> wrote in message
news:uH**************@tk2msftngp13.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******@savagetiger.org> wrote in message news:3f***********************@news.euronet.nl...
Dear Lean,

I usualy have something as this function in my programs:

Function CorrectPath(strPath) As String
'I hope it's just a directory name that has been send as a
parameter...Sometimes 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...Directories 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**********************@xaman.com> wrote in message
news:#6**************@TK2MSFTNGP10.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(strDirectory, strDirectory.Length-1 )

hope this helps,

Leon

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

message
news:3f***********************@news.euronet.nl...
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:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\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.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" =
"C:\CorrectDirectoryEndingWithASlash\\Filename.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"...the 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...aside 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:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\Filename.ext"

Use:

Imports System.IO

Dim drive As String = "C:"
Dim directory As String = "\WrongDirectoryWithoutSlash"
Dim file As String = "Filename.ext"
Dim path As String

path = Path.Combine(drive, directory)
path = Path.Combine(path, file)

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

directory = directory.Trim(Path.DirectorySeparatorChar,
Path.AltDirectorySeperatorChar)

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******@savagetiger.org> wrote in message
news:3f***********************@news.euronet.nl...
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:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\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.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" =
"C:\CorrectDirectoryEndingWithASlash\\Filename.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"...the 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********@email.msn.com> wrote in message
news:#m**************@TK2MSFTNGP11.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:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\Filename.ext"

Use:

Imports System.IO

Dim drive As String = "C:"
Dim directory As String = "\WrongDirectoryWithoutSlash"
Dim file As String = "Filename.ext"
Dim path As String

path = Path.Combine(drive, directory)
path = Path.Combine(path, file)

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

directory = directory.Trim(Path.DirectorySeparatorChar,
Path.AltDirectorySeperatorChar)

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******@savagetiger.org> wrote in message news:3f***********************@news.euronet.nl...
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:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\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.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" =
"C:\CorrectDirectoryEndingWithASlash\\Filename.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"...the 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...The 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**********************@xaman.com> wrote in message news:#T**************@TK2MSFTNGP09.phx.gbl...

Let me ask you a question...aside 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
> Should we not set a new standard?
Paths ending with a slash is logical.
Although I've never had a problem with what you describe, I do agree with you that making an explicit distinction at all times would be more readable. Then again the .NET Framework Directory and File classes do abstract this distinction for you if you program to them rather than digging down directly to the FS itself. Personally I'd rather not have to use explicit paths in my code at all if I can avoid it ;o)

regards,

Leon

"BoonHead, The Lost Philosopher" <bo**************@savagetiger.org> wrote in message news:3f***********************@news.euronet.nl...
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...The 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**********************@xaman.com> wrote in message news:#T**************@TK2MSFTNGP09.phx.gbl...

Let me ask you a question...aside 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 #11
IMHO this is all the fault of the operating system and is caused by
ambiguity on the syntax windows uses to specify file and directory names. in
VMS you would say

c:[progam files.myapp]myapp.exe

which is completely unambiguous. to refer to a directory you say

c:[progam files.myapp]

and if you explicitly want to access a directory as a file you could say

c:[program files]myapp

I presume this is one of the features from dos that was "inspired by" unix
and it was a careless mistake to copy it. Far worse was copying the unix
idea of a 'path' variable but that's another story.
"Leon Jollans" <Le**********************@xaman.com> wrote in message
news:uz*************@TK2MSFTNGP11.phx.gbl...
Should we not set a new standard?
Paths ending with a slash is logical.
Although I've never had a problem with what you describe, I do agree with
you that making an explicit distinction at all times would be more readable.
Then again the .NET Framework Directory and File classes do abstract this
distinction for you if you program to them rather than digging down directly
to the FS itself. Personally I'd rather not have to use explicit paths in my
code at all if I can avoid it ;o)

regards,

Leon

"BoonHead, The Lost Philosopher" <bo**************@savagetiger.org> wrote in
message news:3f***********************@news.euronet.nl...
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...The 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**********************@xaman.com> wrote in message
news:#T**************@TK2MSFTNGP09.phx.gbl...

Let me ask you a question...aside 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 #12

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

Similar topics

0
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
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...
3
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...
2
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
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,...
5
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;...
11
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...
2
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? ...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
agi2029
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 project—planning, coding, testing,...

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.