Solved

Retrieve Full FilePath from saved file using Mapped Drives

Posted on 2007-11-19
2
765 Views
Last Modified: 2013-12-18
I have lotusscript that is detaching OLE objects to end user selected file location.  If the user uses a mapped drive I want my script to determine the actual file location on the server.  
ie.
if "Z:\filename.xxx is returned, I need to know server and filepath.
ie.
\\server\filpath\filename.xxx
0
Comment
Question by:Robert Treadwell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 20317077
You will need to capture the list of all the mapped drives possibly by using the net command  to show and output to a text file that you can read, or with WIn32 API , and then substitute as needed.

net use > list01.txt

should show the connected, mapped drives.
You will need to parse it and then substitute as needed.


I hope this helps !

0
 
LVL 31

Accepted Solution

by:
qwaletee earned 250 total points
ID: 20322980

Function ConvertToUNC(Byval letterPath As String) As String
	If Left$(letterPath,2) = "\\" Then 'already a full UNC
		ConvertToUNC = letterPath
		Exit Function
	Elseif Left$(letterPath,1) = "\" Then 'path off current drive
		letterPath = Curdrive$ & letterPath
	REM two possibilities left, either it is a DOS path (x:\folder) or just a folder (NOTES\DATA) that needs current directory in front
	Elseif Mid$(letterPath,2,1) <> ":" Then
		letterPath = Curdir$ & "\" & letterPath
	End If
	
	Dim drive As String, tree As String, network As Variant, drives As Variant, index As Integer, limit As Integer
	drive = Ucase(Left$(letterPath,2))
	tree = Mid$(letterPath,3)
	Set network = CreateObject("WScript.Network")
	Set drives = network.EnumNetworkDrives()
	limit = drives.Count()-1 '0 index, so count is one above the Ubound
	For index = 0 To limit Step 2
		If Ucase(drives(index)) = drive Then
			ConvertToUNC = drives(index+1) & tree
			Exit Function
		End If
	Next index
	ConvertToUnc = drive & tree
End Function

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question