2012-02-09 6 views
1

У меня есть сервер с несколькими общими папками. Я не знаю их имен, просто ipaddress. Моя первая попытка с:Получить все общие каталоги на удаленном сервере

File rootFolder = new File(rootFolderPath); 
String[] strings = rootFolder.list(); 

не работает.

Итак, есть ли способ в java для получения всех общих папок на сетевом ресурсе?

+0

http://stackoverflow.com/questions/3830847/how-to-get-all-the-shared-folders-in-windows-xp- using-java –

+0

Является ли общая папка той же операционной системой, что и ваш код? –

+0

Не думайте так. Я на окнах, это NAS – jussi

ответ

1

Клиентская библиотека JCIFS SMB позволяет Java-приложениям удаленный доступ к общим файлам и каталогам на файловом сервере SMB (т. Е. Общий доступ к Microsoft Windows) в дополнение к перечислению доменов, рабочих групп и серверов NetBIOS через сети TCP/IP.

см http://jcifs.samba.org/src/docs/api/

public java.lang.String[] list() 
         throws SmbException 

    List the contents of this SMB resource. The list returned by this method will be; 

     files and directories contained within this resource if the resource is a normal disk file directory, 
     all available NetBIOS workgroups or domains if this resource is the top level URL smb://, 
     all servers registered as members of a NetBIOS workgroup if this resource refers to a workgroup in a smb://workgroup/ URL, 
     all browseable shares of a server including printers, IPC services, or disk volumes if this resource is a server URL in the form smb://server/, 
     or null if the resource cannot be resolved. 

    Returns: 
     A String[] array of files and directories, workgroups, servers, or shares depending on the context of the resource URL 
    Throws: 
     SmbException 

см http://jcifs.samba.org/src/docs/api/jcifs/smb/SmbFile.html#list%28%29

+0

Пробовал этот. Возвращает 0 файлов/каталогов в SMB – jussi

Смежные вопросы