PC Review


Reply
Thread Tools Rate Thread

Converting file path.

 
 
Tim Marsden
Guest
Posts: n/a
 
      3rd Mar 2004
Hi,

Given a file Path, for example "C:\Data\Samples".
How do I convert this to "\\Server\Share\Data\Samples"
The original "C:" , "F:" etc may be local or a mapped network drive.
I am trying to ensure the path (stored as sting in database) is valid from
any machine, regardless of the drive mappings and shares on the machine.

any suggestions,
Tim




 
Reply With Quote
 
 
 
 
Cor
Guest
Posts: n/a
 
      3rd Mar 2004
Hi Tim,

I think that than the best thing you can do is using the directeryinfo and
see if it is in that.

Not checked,

Probably you will have to set that in a try block.

I hope this helps?

Cor

>
> Given a file Path, for example "C:\Data\Samples".
> How do I convert this to "\\Server\Share\Data\Samples"
> The original "C:" , "F:" etc may be local or a mapped network drive.
> I am trying to ensure the path (stored as sting in database) is valid

from
> any machine, regardless of the drive mappings and shares on the machine.
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      3rd Mar 2004
* "Tim Marsden" <(E-Mail Removed)> scripsit:
> Given a file Path, for example "C:\Data\Samples".
> How do I convert this to "\\Server\Share\Data\Samples"
> The original "C:" , "F:" etc may be local or a mapped network drive.
> I am trying to ensure the path (stored as sting in database) is valid from
> any machine, regardless of the drive mappings and shares on the machine.


What do you mean with "valid"? Do you want to check if the path exists?
Have a look at the 'System.IO' namespace, 'Directory.Exists'.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
 
Reply With Quote
 
Tim Marsden
Guest
Posts: n/a
 
      4th Mar 2004
FYI

I have used a combination of API's WNetGetUniversalName and NetShareEnum.
WNetGetUniversalName gives you the mapped drives, NetShareEnum gives you the
local shared drives. By checking both of these you can establish the UNC
name of a folder or file.

Tim

"Tim Marsden" <(E-Mail Removed)> wrote in message
news:ue$(E-Mail Removed)...
> Hi,
>
> Given a file Path, for example "C:\Data\Samples".
> How do I convert this to "\\Server\Share\Data\Samples"
> The original "C:" , "F:" etc may be local or a mapped network drive.
> I am trying to ensure the path (stored as sting in database) is valid

from
> any machine, regardless of the drive mappings and shares on the machine.
>
> any suggestions,
> Tim
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting from UNC to local path karanovicm@gmail.com Microsoft VB .NET 0 14th Feb 2007 05:32 AM
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Microsoft Excel Worksheet Functions 1 22nd Nov 2006 05:16 PM
Converting a UNC path to a physical file path =?Utf-8?B?U2ltb24=?= Microsoft Dot NET 2 29th Oct 2004 01:04 AM
Converting Long Directory Path's To Short Path's =?Utf-8?B?ZG90TmV0RGF2ZQ==?= Microsoft Dot NET 2 1st Oct 2004 05:17 PM
Converting absolute path to relative Dmitry Shaporenkov Microsoft Dot NET Framework 0 25th Sep 2003 05:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:47 AM.