I am using visual studio 2019 and cannot read the list of files in a directory. I have changed my code to keep it very simple with the same error.
I keep gettin this error: System.IO.DirectoryNotFoundException: 'Could not find a part of the path '/C:\'.' not sure why
Here is the code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using System.IO;
namespace HMSsystem.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PDFViews : ContentPage
{
public PDFViews()
{
InitializeComponent();
}
private async void OnPDBBtnClicked(object sender, EventArgs e)
{
var Paths = new List<String>();
//string path = "C:\\";
foreach (string path in Directory.EnumerateFiles("C:\\"))
{
Console.WriteLine("IN C DIRECTORY: " + path);
}
//DirectoryInfo dir = new DirectoryInfo(path);
//foreach (FileInfo flInfo in dir.EnumerateFiles("*",SearchOption.AllDirectories))
//{
// String name = flInfo.Name;
// long size = flInfo.Length;
// DateTime creationTime = flInfo.CreationTime;
// Paths.Add(name);
//}
//if (Directory.Exists(path))
//{
// foreach (var file1 in System.IO.Directory.GetFiles(path))
// {
// if (file1 != null)
// {
// Paths.Add(file1);
// }
// }
//}
await Shell.Current.GoToAsync("//LoginPage");
}
}
}
Any help would be appreaciated
Thank You
Tom
