i have routine for store somes documents into one directory wich run on local drive but get error with network drive if i use path as this "\\172.16.3.145\Directory".
i use this code for create subdirectory needed:
If My.Computer.FileSystem.DirectoryExists(PercorsoDocumenti) = False Then
My.Computer.FileSystem.CreateDirectory(PercorsoDocumenti)
End If
If My.Computer.FileSystem.DirectoryExists(PercorsoOrdini) = False Then
My.Computer.FileSystem.CreateDirectory(PercorsoOrdini)
End If
'+++ creazione della sottodirectory per l'ordine che deve sempre esistere per poter consultare i files presenti +++
If My.Computer.FileSystem.DirectoryExists(PercorsoOrdini & lblIdOrdinePassato.Text) = False Then
My.Computer.FileSystem.CreateDirectory(PercorsoOrdini & lblIdOrdinePassato.Text)
End If
LstViewDocumentiCaricati.Clear()
For Each fileName As String In IO.Directory.GetFiles(PercorsoOrdini & lblIdOrdinePassato.Text)
ImgLstFiles.Images.Add(Icon.ExtractAssociatedIcon(fileName))
LstViewDocumentiCaricati.Items.Add(IO.Path.GetFileName(fileName), ImgLstFiles.Images.Count - 1)
Next
This code work and create directory also in path as "\\server\directory" but get error when i try to list all files in a listview with this other code:
For Each fileName As String In IO.Directory.GetFiles(PercorsoOrdini & lblIdOrdinePassato.Text)
ImgLstFiles.Images.Add(Icon.ExtractAssociatedIcon(fileName))
LstViewDocumentiCaricati.Items.Add(IO.Path.GetFileName(fileName), ImgLstFiles.Images.Count - 1)
Next
The error happen also if i share directory with sufficient permission...it create directory on network drive but go on error when try to list files.
The error are similar to this:
Value of \172.16.3.145\Directory\Docs\document.pdf is not a valid path for filePath
I'm not able to debug in production computer, so i think the error is in listing procedure code because all code firs work (create directory on network drive).
Someone could help me to understand why ?