我正在尝试将图像从外部设备复制到网络上的文件夹,但我的代码问题是它在本地驱动器(c :)中创建一个文件夹并处理图像。但我在网络上有这个文件夹。 它应该只创建一个包含今天日期的文件夹并复制网络上的图像。
string _ftpURL = @"00.000.00.0"; //Host URL or address of the SFTP server
//string _ftpURL = @"0.0.0.0";
string _UserName = "root"; //User Name of the SFTP server
string _Password = "3p1"; //Password of the SFTP server
int _Port = 2222; //Port No of the SFTP server (if any)
string _ftpDirectory = "/opt/prassel/data/snap/*.jpg"; //The directory in SFTP server where the files will be uploaded
var LocalDirectory = string.Format("\\ws4.lboro.ac.uk\\SY0-1ticketPhotofolder\\TICKET PHOTO'S\\{0:yyyy-MM-dd}", DateTime.Now);
System.IO.Directory.CreateDirectory(LocalDirectory);
Sftp Connection = new Sftp(_ftpURL, _UserName, _Password);
Connection.Connect(_Port);
Connection.Get(_ftpDirectory, LocalDirectory);
Connection.Close();
答案 0 :(得分:2)
远程UNC轻拍以两个斜杠开头。假设ws4.lboro.ac.uk
是服务器名称:
var LocalDirectory = string.Format("\\\\ws4.lboro.ac.uk\\SY0-1ticketPhotofolder\\TICKET PHOTO'S\\{0:yyyy-MM-dd}", DateTime.Now);
或只是
var LocalDirectory = string.Format(@"\\ws4.lboro.ac.uk\SY0-1ticketPhotofolder\TICKET PHOTO'S\{0:yyyy-MM-dd}", DateTime.Now);