C# 通过SSL连接到站点文件夹

C# 通过SSL连接到站点文件夹,c#,ssl,webdav,C#,Ssl,Webdav,好吧,这件事我很难理解,但让我解释一下发生了什么。我有一个使用https的sharepoint站点。我写了一个c程序从那个网站的文件夹下载文件。我到那个文件夹的路径是 string pathA = @"\\mysite.com@SSL\DavWWWRoot\sites\abc\Lists\Images\Screen Slides\"; 所以问题是,当您启动计算机时,代码将抛出错误:FolderNotFound。我的解决方法是让C程序打开文件夹,这需要两个步骤,我不知道如何编码。我将把这个URL

好吧,这件事我很难理解,但让我解释一下发生了什么。我有一个使用https的sharepoint站点。我写了一个c程序从那个网站的文件夹下载文件。我到那个文件夹的路径是

string pathA = @"\\mysite.com@SSL\DavWWWRoot\sites\abc\Lists\Images\Screen Slides\";
所以问题是,当您启动计算机时,代码将抛出错误:FolderNotFound。我的解决方法是让C程序打开文件夹,这需要两个步骤,我不知道如何编码。我将把这个URL打开到一个run命令中,它会说第一次尝试就无法连接。然后我再次运行它,它将连接。因此,需要两个run命令才能连接到文件夹。在此之后,C程序将不会出现查找和访问文件夹的问题

我的猜测是,我需要为我的C代码使用某种凭据来连接到该文件夹,而无需进行变通。我正在寻找一种方法,以连接到该网站的代码,这样用户就不必改变他们的机器上的任何设置。谢谢

编辑:下面是将SSL文件夹与本地directoy进行比较的代码。它将从那里下载或删除文件

string pathA = @"\\mysite.com@SSL\DavWWWRoot\sites\abc\Lists\Images\Screen Slides\";
string pathB = imagepath;

System.IO.DirectoryInfo dir1 = new System.IO.DirectoryInfo(pathA);
System.IO.DirectoryInfo dir2 = new System.IO.DirectoryInfo(pathB);

// Take a snapshot of the file system.
IEnumerable<System.IO.FileInfo> list1 = dir1.GetFiles("*.*", System.IO.SearchOption.TopDirectoryOnly);
IEnumerable<System.IO.FileInfo> list2 = dir2.GetFiles("*.*", System.IO.SearchOption.TopDirectoryOnly);

//A custom file comparer defined below
FileCompare myFileCompare = new FileCompare();

// Find the set difference between the two folders. 
// Check if there is new images in network drive and if not download to C. 
var queryList1Only = (from file in list1
      select file).Except(list2, myFileCompare);

Console.WriteLine("The following files are in list1 but not list2:");
foreach (var v in queryList1Only)
{
    File.Copy(v.FullName, Path.Combine(pathB, v.Name));
    Console.WriteLine("Download done");
    Console.WriteLine(v.FullName);
}

// Find the set difference between the two folders. 
// Check if there is old images in C drive and if so delete them. 
var queryList2Only = (from file in list2
      select file).Except(list1, myFileCompare);

Console.WriteLine("The following files are in C:/ but not \\share:");
foreach (var v in queryList2Only)
{  
    File.Delete(v.FullName);
    Console.WriteLine("Delete done");
    Console.WriteLine(v.FullName);
}

// Keep the console window open in debug mode.
Console.WriteLine("File Sync Done");

请共享您正在使用的实际使用pathA变量的代码。I:您到底在做什么来下载这些文件?问题不是下载,而是连接到文件夹。如果我使用@\\mysite.com\sites\abc\Lists\Images\Screen Slides\,我将编辑帖子以添加刚刚发现的代码;我也有同样的问题