问题描述:使用jcifs jar包操作共享文件,将本地文件上传至服务器共享区遇见Exception:jcifs.smb.SmbException: The network name cannot be found. 但是同样的代码将文件上传至虚拟机共享区就可以。 本机操作系统:win10,服务器:winserver 2012,虚拟机:winserver 2008
代码如下:
InputStream in = null;
OutputStream out = null;
//本地文件位置
File localFile = new File("F:"+File.separator+"test"+File.separator+"cc.jpg");
String fileName = localFile.getName();
//存放文件的共享文件夹目录
String remotePhotoUrl = "smb://192.168.56.142/Windchill/test";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("", "winserver", "!qaz2wsx");
SmbFile remoteFile = new SmbFile(remotePhotoUrl+File.separator+fileName,auth);
//建立连接
remote