Visual Basic - Carpetas de red

Life is soft - evento anual de software empresarial
 
Vista:

Carpetas de red

Publicado por Low (102 intervenciones) el 15/03/2006 08:23:24
Hola, he estado buscando y no se si estaré muy espeso o que, pero no encuentro lo siguiente, a ver si alguien me puede ayudar.

Necesito comprobar que existe una determinada carpeta, tanto si está en local (ej. "C:\CARPETA\") como si esta en red (ej. "\\PC\CARPETA\"); he pensado en hacerlo con un simple y llano Dir, pero resulta que cuando la carpeta es en red el equipo se me queda colgado. He probado también la función OpenFile, pero sólo me es válida en archivos.

Si alguien sabe como comprobar la existencia de una carpeta en red se lo agradecería muchísimo.

PD: ya puestos también necesito saber si el usuario tiene o no permisos en la carpeta en cuestión, pero esto es secundario.

Muchas gracias por la atención.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Carpetas de red

Publicado por LL (3 intervenciones) el 15/03/2006 09:41:14
Hola creo que este ejemplo te viene bien. Cualquier cosa si falla, ya que no tengo nua Lan para probar, bajate el Apiguide, instalalo y en la opcion buscar, pone Path que te salen varios ejemplo y funciones relacionados.

Private Declare Function PathIsDirectory Lib "shlwapi.dll" Alias "PathIsDirectoryA" (ByVal pszPath As String) As Long
Private Declare Function PathIsDirectoryEmpty Lib "shlwapi.dll" Alias "PathIsDirectoryEmptyA" (ByVal pszPath As String) As Long
Private Declare Function PathIsLFNFileSpec Lib "shlwapi.dll" Alias "PathIsLFNFileSpecA" (ByVal lpName As String) As Long
Private Declare Function PathIsNetworkPath Lib "shlwapi.dll" Alias "PathIsNetworkPathA" (ByVal pszPath As String) As Long
Private Declare Function PathIsPrefix Lib "shlwapi.dll" Alias "PathIsPrefixA" (ByVal pszPrefix As String, ByVal pszPath As String) As Long
Private Declare Function PathIsRelative Lib "shlwapi.dll" Alias "PathIsRelativeA" (ByVal pszPath As String) As Long
Private Declare Function PathIsRoot Lib "shlwapi.dll" Alias "PathIsRootA" (ByVal pszPath As String) As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'set the form's graphical omde to 'persistent'
Me.AutoRedraw = True
'check whether a specified dir exists
Me.Print "Does the directory C:\windows exist? " + CStr(CBool(PathIsDirectory("c:\windows")))
'check whether a dir contains files
Me.Print "Is the directory 'c:\windows' empty? " + CStr(CBool(PathIsDirectoryEmpty("c:\windows")))
'check whether a file is in long format
Me.Print "Is the specified file in long format? " + CStr(CBool(PathIsLFNFileSpec("c:\mydir\verylongfile.extension")))
'check whether a specified path is a network resource
Me.Print "Is the specified path a network path? " + CStr(CBool(PathIsNetworkPath("\\Server\C$\test.txt")))
'check whether a path contains a specific prefix
Me.Print "Does the path contain the prefix? " + CStr(CBool(PathIsPrefix("d:\", "c:\mydir\test.txt")))
'check whether a path is relative or absolute
Me.Print "Is the path relative? " + CStr(CBool(PathIsRelative("c:\test.txt")))
'check whether a path is a root path
Me.Print "Is this a root path? " + CStr(CBool(PathIsRoot("z:\")))
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Carpetas de red

Publicado por LL (3 intervenciones) el 15/03/2006 09:41:15
Hola creo que este ejemplo te viene bien. Cualquier cosa si falla, ya que no tengo nua Lan para probar, bajate el Apiguide, instalalo y en la opcion buscar, pone Path que te salen varios ejemplo y funciones relacionados.

Private Declare Function PathIsDirectory Lib "shlwapi.dll" Alias "PathIsDirectoryA" (ByVal pszPath As String) As Long
Private Declare Function PathIsDirectoryEmpty Lib "shlwapi.dll" Alias "PathIsDirectoryEmptyA" (ByVal pszPath As String) As Long
Private Declare Function PathIsLFNFileSpec Lib "shlwapi.dll" Alias "PathIsLFNFileSpecA" (ByVal lpName As String) As Long
Private Declare Function PathIsNetworkPath Lib "shlwapi.dll" Alias "PathIsNetworkPathA" (ByVal pszPath As String) As Long
Private Declare Function PathIsPrefix Lib "shlwapi.dll" Alias "PathIsPrefixA" (ByVal pszPrefix As String, ByVal pszPath As String) As Long
Private Declare Function PathIsRelative Lib "shlwapi.dll" Alias "PathIsRelativeA" (ByVal pszPath As String) As Long
Private Declare Function PathIsRoot Lib "shlwapi.dll" Alias "PathIsRootA" (ByVal pszPath As String) As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'set the form's graphical omde to 'persistent'
Me.AutoRedraw = True
'check whether a specified dir exists
Me.Print "Does the directory C:\windows exist? " + CStr(CBool(PathIsDirectory("c:\windows")))
'check whether a dir contains files
Me.Print "Is the directory 'c:\windows' empty? " + CStr(CBool(PathIsDirectoryEmpty("c:\windows")))
'check whether a file is in long format
Me.Print "Is the specified file in long format? " + CStr(CBool(PathIsLFNFileSpec("c:\mydir\verylongfile.extension")))
'check whether a specified path is a network resource
Me.Print "Is the specified path a network path? " + CStr(CBool(PathIsNetworkPath("\\Server\C$\test.txt")))
'check whether a path contains a specific prefix
Me.Print "Does the path contain the prefix? " + CStr(CBool(PathIsPrefix("d:\", "c:\mydir\test.txt")))
'check whether a path is relative or absolute
Me.Print "Is the path relative? " + CStr(CBool(PathIsRelative("c:\test.txt")))
'check whether a path is a root path
Me.Print "Is this a root path? " + CStr(CBool(PathIsRoot("z:\")))
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Carpetas de red

Publicado por LLE (3 intervenciones) el 15/03/2006 09:41:47
Hola creo que este ejemplo te viene bien. Cualquier cosa si falla, ya que no tengo nua Lan para probar, bajate el Apiguide, instalalo y en la opcion buscar, pone Path que te salen varios ejemplo y funciones relacionados.

Private Declare Function PathIsDirectory Lib "shlwapi.dll" Alias "PathIsDirectoryA" (ByVal pszPath As String) As Long
Private Declare Function PathIsDirectoryEmpty Lib "shlwapi.dll" Alias "PathIsDirectoryEmptyA" (ByVal pszPath As String) As Long
Private Declare Function PathIsLFNFileSpec Lib "shlwapi.dll" Alias "PathIsLFNFileSpecA" (ByVal lpName As String) As Long
Private Declare Function PathIsNetworkPath Lib "shlwapi.dll" Alias "PathIsNetworkPathA" (ByVal pszPath As String) As Long
Private Declare Function PathIsPrefix Lib "shlwapi.dll" Alias "PathIsPrefixA" (ByVal pszPrefix As String, ByVal pszPath As String) As Long
Private Declare Function PathIsRelative Lib "shlwapi.dll" Alias "PathIsRelativeA" (ByVal pszPath As String) As Long
Private Declare Function PathIsRoot Lib "shlwapi.dll" Alias "PathIsRootA" (ByVal pszPath As String) As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'set the form's graphical omde to 'persistent'
Me.AutoRedraw = True
'check whether a specified dir exists
Me.Print "Does the directory C:\windows exist? " + CStr(CBool(PathIsDirectory("c:\windows")))
'check whether a dir contains files
Me.Print "Is the directory 'c:\windows' empty? " + CStr(CBool(PathIsDirectoryEmpty("c:\windows")))
'check whether a file is in long format
Me.Print "Is the specified file in long format? " + CStr(CBool(PathIsLFNFileSpec("c:\mydir\verylongfile.extension")))
'check whether a specified path is a network resource
Me.Print "Is the specified path a network path? " + CStr(CBool(PathIsNetworkPath("\\Server\C$\test.txt")))
'check whether a path contains a specific prefix
Me.Print "Does the path contain the prefix? " + CStr(CBool(PathIsPrefix("d:\", "c:\mydir\test.txt")))
'check whether a path is relative or absolute
Me.Print "Is the path relative? " + CStr(CBool(PathIsRelative("c:\test.txt")))
'check whether a path is a root path
Me.Print "Is this a root path? " + CStr(CBool(PathIsRoot("z:\")))
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar