server\share values -- Urgent

Hi,

I have people that say that this can be done. have tried a number of things with no success.

\\unknown\unknown\testfolder\test.txt

the only thing that I know is that there is a folder named testfolder and a file named test.txt.

Is there anyway to get the two unknown values above?


earngreenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

goober7Commented:

If the folders are published in Active Directory, you can programitically use the code on this page to search for them
http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_wkqv.mspx?mfr=true

Or, (also if the folders are published in Active Directory), you can just search for them in AD Users and Computers by right clicking on domain, choose "find", then select "Shared Folders" in the Find drop down box.

IF they are NOT published, you may be stuck with, at a minimum, doing a 'for each' search on every server\share in the domain. This code can at least get you started by
'--Insert a For each loop here For every computer in domain
strComputer = ""
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")

StrConCat = "."

For each objShare in colShares
    'Instead of concatenating these to print them, you'd do a search here.
    StrConCat = StrConCat  &  "Name: " & objShare.Name     & VbTab & VbTab & VbTab
    StrConCat = StrConCat  &  "Path: " & objShare.Path     & VbCrLF
Next
      
wscript.echo strConCat
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
earngreenAuthor Commented:
Sorry that will not work because then I will have to store VBS file with every app. I need something in pure VB.net.
0
Bob LearnedCommented:
Are you trying to find the server name and share name for a file path?

Bob
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

earngreenAuthor Commented:
Yes Bob

Really having a hard time with this one. I am currently working on a couple of things that i found out on the net but never attempted to do anything like this so am a little nervous about what I am going to do.

I found this which will return the network drives on the computer but I need to limit to one or two to search. having trouble with creating an array to store the drives. Then I could convert to a string and concatenate and filter as I would like.

http://www.mvps.org/access/api/api0003.htm

I also found this

http://www.freevbcode.com/ShowCode.asp?ID=446

Don't know anything about VB6 trying to pass the filename as a parameter to the class and see what happens.

Any suggestions on how to find server name and share name and concatenate the file path?


0
Bob LearnedCommented:
I am still trying to figure out, though, if you have the full UNC name, or just a file name, without knowing the server name?  Or, do you want to search through mapped networks drives for that file path?

Bob
0
earngreenAuthor Commented:
I do not have the full UNC name. This is the problem.

For instance,

this part is known

\testfolder\test.txt

and this part is unknown

\\servername\share

Ideally I would like to get the server name and sharepath.
0
earngreenAuthor Commented:
Bob

I created this from the Code on this page using the fGetUNCPath function from http://www.mvps.org/access/api/api0003.htm  I am trying to store all the drives in array but having trouble with the array. I then will store the items in an array and concatenate the path. Then I want to check to see if the file exists, if so then complete the operation. If not return a message that says file not found.

The array below does not display properly. Not sure what the issue is. I also tried to
TotalUNCPath = ShowArray to return the array for display in a Sub but returned no values.

Any ideas?


Dim strAllDrives As String
        Dim strTmp As String
        Dim strTemp As String
        Dim StrReturnDrives As String
        Dim SfileName As String
        Dim UNCPath As String
        Dim i As Integer
        Dim UniversalPath As String

        strAllDrives = fGetDrives()
       
        If strAllDrives <> "" Then
           
            Do
                strTmp = Mid(strAllDrives, 1, InStr(strAllDrives, vbNullChar) - 1)
                'strTmp = Mid(strAllDrives, 1, InStr(strAllDrives, vbNullChar) + 1)
                strAllDrives = Mid(strAllDrives, InStr(strAllDrives, vbNullChar) + 1)

                Select Case fDriveType(strTmp)

                    Case "Network Drive"

                       
                     UniversalPath = ((fGetUNCPath(Microsoft.VisualBasic.Left(strTmp, Len(strTmp) - 1).ToString)))


                        SfileName = UniversalPath
                       
                        Dim ShowArray As String
                       
                        Dim strArray(Len(SfileName)) As String
                        For i = 1 To Len(SfileName)
                            strArray(i) = strArray(i) & Mid(SfileName, i, 1)
                            ShowArray = strArray(i)
                            Debug.WriteLine(ShowArray)
                        Next
                       
                End Select


         Loop While strAllDrives <> ""
     


        End If
       

    End Function
0
Bob LearnedCommented:
No ideas.

Bob
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.