c# - Connection to Site folder via SSL -
ok 1 hard me head around let me explain happening. have sharepoint (maybe irrelevant) site uses https. wrote c# program download files folder site. path folder is
string patha = @"\\mysite.com@ssl\davwwwroot\sites\abc\lists\images\screen slides\";
so issue when boot machine, code throw error: folder not found. workaround getting c# program open folder takes 2 steps not know how code. open url run command cannot connect first try. run again connect. takes 2 run commands connect folder. after c# program have not issues finding , accessing folder.
my guess need use sort of credentials c# code connect folder without doing work around. looking way connect site code users not have change settings on machine. thanks
edit: here code compare ssl folder local directoy. there download or delete files
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 snapshot of 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 set difference between 2 folders. // check if there new images in network drive , if not download c. var querylist1only = (from file in list1 select file).except(list2, myfilecompare); console.writeline("the following files in list1 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 set difference between 2 folders. // check if there old images in c drive , if delete them. var querylist2only = (from file in list2 select file).except(list1, myfilecompare); console.writeline("the following files in c:/ not \\share:"); foreach (var v in querylist2only) { file.delete(v.fullname); console.writeline("delete done"); console.writeline(v.fullname); } // keep console window open in debug mode. console.writeline("file sync done");
Comments
Post a Comment