473,407 Members | 2,629 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,407 software developers and data experts.

Converting file path.

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


Nov 20 '05 #1
3 1259
Cor
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.

Nov 20 '05 #2
* "Tim Marsden" <TM@UK.COM> 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/>
Nov 20 '05 #3
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" <TM@UK.COM> wrote in message
news:ue**************@TK2MSFTNGP09.phx.gbl...
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

Nov 20 '05 #4

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

Similar topics

2
by: Simon | last post by:
I wonder if someone can help with this - I 'm creating an IISVirtualDirectory, and setting its Path property to the physical path I want to reference. This works fine when I have a standard file...
3
by: j.a. harriman | last post by:
Hi, On MSDN I know there is a JScript example (Upgrading Visual C++ Projects to Visual Studio .NET in Batch Mode) to upgrade VS6 C++ projects to .NET solutions. It converts the project files...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
9
by: Michael Tissington | last post by:
After converting from 6.0 to 2005 when I try to Compile my project I'm getting a LINK error Error 1 fatal error LNK1181: cannot open input file " ?/.obj" Any ideas how to fx this please ? ...
6
by: Dennis D. | last post by:
Having problems converting Murach's Beginning Visual Basic.net (Prince) and Microsoft Press' Programming Visual Basic.net (Balena) examples for use in VB.net 2005 Express. The VS conversion wizard...
0
by: anide | last post by:
Hi all I’ve some problem, I’m trying to converting a sorting algorithm from C++ to C#. In C++ I’ve compiled it using MSVC and its working properly, and in C# I’m using .NET Framework 2.0 (Visual...
17
by: > Adrian | last post by:
I have converted a number of applications to enable them to work together on a network. I have been led to believe that I can do this as follows: FileStream fs = new FileStream(some code); while...
6
by: shredder249 | last post by:
Hi, i have a form which displays records containing a filepath field. When a button is pressed all the filepath fields are checked and the form is refiltered to display only those with invalid file...
1
by: David Buckley | last post by:
Does anyone have any example code of converting any type of video to flash video at all using asp.net 2.0 c# web applications. God Bless
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.