473,796 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting file path.

Hi,

Given a file Path, for example "C:\Data\Sample s".
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 1279
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\Sample s".
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\Sample s".
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.Exis ts'.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #3
FYI

I have used a combination of API's WNetGetUniversa lName and NetShareEnum.
WNetGetUniversa lName 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******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

Given a file Path, for example "C:\Data\Sample s".
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
3111
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 path - 'C:/Test' - however I sometimes have a UNC path - '//remoteComputer/Test' - and IIS appears to choke when it's given that. So, is there any way of translating a UNC path to the physical path on the remote computer? ie: Translating '...
3
3115
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 (*.dsp), but doesn't create the solution (*.sln) file. Is there an automated way to convert an existing VS6 C++ *.dsw to a .NET *.sln?
5
2527
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 applications. I am testing an upgrade of all of the sites and have converted the main root site...although not necessarily fixed any issues. I move on instead and converted one of the virtual roots that is a seperate
9
1634
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 ? -- Michael Tissington http://www.oaklodge.com
6
1812
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 has not been able to convert any of them. These are just two example sources of many. What should I be doing to convert these samples, or should I reinstall VB.net 2003? Dennis D., http://www.dennisys.com/
0
2033
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 Studio 2005). The problem occurred when I trying to opening and reading file: ============= C++ ============= void LoadSourceFile(char * fileName, unsigned char * data, int length)
17
1618
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 (!fs.CanRead){allow the processor to handle another thread;} Hoverer, doing some tests I find out that the solution isn't working. Is there a simple way out?
6
3301
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 paths. Upon pressing a second button each file is searched for on the computer. Currently all the matches are just written to a list box. What i want to happen is if there is only one match then that match's file path is written to the record's file...
1
2808
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
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
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
10459
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
10237
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
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.