elgdav said:
Hello, is it possible in C#.Net to get a path to a file in the form
"\\Spain\Madrid\readme.txt" from a relative path i.e "readme.txt" or
from a absolute path in the following form "C:\Madrid\readme.txt" where
"Spain" is the name of the machine that the file is on? Thanks in
advance.
I don't think you're going to find anything simply baked into
..Net/Win32 to do this.
Think of the following file:
C:\A\B\C\D\Blah.txt
File ACLs are set to Everyone/Full Control. D is shared and has
security set such that only Domain Administrators can access the share.
C is shared and has security set such that Domain Users can access it.
B is shared such that Everyone can access it.
Having set the scene, imagine that you want to get a UNC path to
C:\A\B\C\D\Blah.txt. What should your imagined function return? Any of
\\machine\B\C\D\Blah.txt, \\machine\C\D\Blah.txt or
\\machine\D\Blah.txt may be the correct answer. Which is correct is
something the system cannot determine.
Of course, the above model is hopelessly flawed from a security
perspective, since if people are aware of the hierarchy, they can
always access via B, but it was to demonstrate that multiple shares
with alternate security permissions may exist, and the correct decision
is not something that the system can infer.
Damien