Apr 08 2021 04:48 AM
Hi,
I'm trying to integrate Sharepoint to our windows application using "Microsoft.SharePoint.Client". The ultimate goal is to download a selected file from the sharepoint folder. From my application I need to list out the sharepoint files in the file explorer using the UNC path. It works for a while only when I login to the sharepoint site using Internet Explorer. After a certain period of sign out, it returns "Network path not found". I can't access the UNC path in windows explorer either. Please help me out to resolve this issue. My code snippet is,
var filePath = @"\\xxxx.sharepoint.com\sites\documents";
System.Diagnostics.Process.Start(@"c:\windows\system32\net.exe", $@"use {filePath}");
Stream myStream;
var openFileDialog = new OpenFileDialog
{
InitialDirectory = filePath,
RestoreDirectory = true
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
if ((myStream = openFileDialog.OpenFile()) != null)
{
var destinationPath = Path.Combine(GetDestinationDirectory(), Path.GetFileName(openFileDialog.FileName));
using (var fileStream = new FileStream(destinationPath, FileMode.Create, FileAccess.Write))
{
myStream.CopyTo(fileStream);
}
myStream.Close();
}
}