I am attempting to compare a variable "windir" to the root folder from a browser dialog. At the moment the error I am getting is "Cannot implicitly convert type System.Environment.SpecialFolder to string". Anything I try makes it worse. Below is my code. The issue is with btn4. It is not a syntax issue. == does not work.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
using System.IO;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Windows.Shell;
namespace Client_Backup
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : System.Windows.Window
{
private string windir;
public MainWindow()
{
InitializeComponent();
windir = System.IO.Path.GetPathRoot(Environment.SystemDirectory);
//tb2.Text = windir;
}
private void btn2_Click(object sender, RoutedEventArgs e)
{
for (int i = LB1.SelectedItems.Count - 1; i >= 0; i--)
{
LB1.Items.Remove(LB1.SelectedItems[i]);
}
}
private void btn1_Click(object sender, RoutedEventArgs e)
{
if (new FolderBrowserDialog().ShowDialog() == System.Windows.Forms.DialogResult.OK)
LB1.Items.Add(new FolderBrowserDialog().SelectedPath);
}
private void btn3_Click(object sender, RoutedEventArgs e)
{
}
private void btn4_Click(object sender, RoutedEventArgs e)
{
//tb2.Text = windir;
FolderBrowserDialog folderselect = new FolderBrowserDialog();
if (folderselect.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (windir = folderselect.RootFolder)
{
tb2.Text = "you have selected the system drive for a backup destination. please select a different drive.";
}
tb1.Text = (folderselect.SelectedPath);
}
}
private void tb1_TextChanged(object sender, TextChangedEventArgs e)
{
tb1.Background = Brushes.FloralWhite;
}
private void btn5_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btn6_Click(object sender, RoutedEventArgs e)
{
if (this.WindowState == WindowState.Maximized)
this.WindowState = WindowState.Normal;
else
this.WindowState = WindowState.Maximized;
}
private void btn7_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void rectangle1_MouseDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void Cbx2Changed(object sender, RoutedEventArgs e)
{
if (cbx2.IsChecked == true)
{
LB1.IsEnabled = false;
btn1.IsEnabled = false;
btn2.IsEnabled = false;
}
else
{
LB1.IsEnabled = true;
btn1.IsEnabled = true;
btn2.IsEnabled = true;
}
}
private void Cbx1Changed(object sender, RoutedEventArgs e)
{
}
}
}
I tried to do a ToString but that didn't work. I'm just stuck.