Click here to Skip to main content
15,911,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have modified this code i found online to list the items on a remote server. We have an application which we dont want to hard code fixes and update the whole application everytime something new comes up. So we have a remtoe share which will be where we place scripts and batch files. When i run the code on a local machine to view folders it pulls the information just fine but when i point it to the remote server location i get:

Value of '\\mcusquanfs01\nrfz helpdesk\RDM_NRFK_WN7\Synergy Lite\Static_Fixes\Application\PKIRecycleSVC.vbs' is not valid for 'filePath'.

the error comes at line:

APP_ImageList.Images.Add(Drawing.Icon.ExtractAssociatedIcon(F.FullName))



Here is my code:

Private Sub Application_Fixes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim Dir As New DirectoryInfo("\\mcusquanfs01\nrfz helpdesk\RDM_NRFK_WN7\Synergy Lite\Static_Fixes\Application\")
    Application_Fixes_List(Dir)
End Sub
Private Sub Application_Fixes_List(ByVal Folder As DirectoryInfo)
    Static APP_ImageList As New ImageList With {.ColorDepth = ColorDepth.Depth32Bit, .ImageSize = New Size(20, 20)}
    Static ImgIndex As Integer = 0
    Application_Fixes_ListView.LargeImageList = APP_ImageList
    Application_Fixes_ListView.View = View.Tile

    For Each F As FileInfo In Folder.GetFiles("*.vbs")
        APP_ImageList.Images.Add(Drawing.Icon.ExtractAssociatedIcon(F.FullName))
        Application_Fixes_ListView.Items.Add(F.Name, ImgIndex)
        ImgIndex += 1
    Next
    For Each F As FileInfo In Folder.GetFiles("*.bat")
        APP_ImageList.Images.Add(Drawing.Icon.ExtractAssociatedIcon(F.FullName))
        Application_Fixes_ListView.Items.Add(F.Name, ImgIndex)
        ImgIndex += 1
    Next
    For Each Dir As DirectoryInfo In Folder.GetDirectories
        Application_Fixes_List(Dir)
    Next
End Sub
Posted
Comments
ZurdoDev 28-Feb-12 8:37am    
You have a space in your path so you need to put " " around it, possibly.
Zachary.shupp 28-Feb-12 8:44am    
I tried it at a location without a space and i have the same issue.
ZurdoDev 28-Feb-12 8:48am    
According to http://msdn.microsoft.com/en-us/library/system.drawing.icon.extractassociatedicon.aspx you cannot use UNC paths.
Zachary.shupp 28-Feb-12 8:53am    
I was looking at that too.
ZurdoDev 28-Feb-12 8:54am    
If you have necessary permissions and they are small files you may try copying them to a folder on the machine where your app is running and then access them. Just a thought.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900