I have a small form app that I wont to browse for network UNC path to then copy a folder im getting the error Cannot convert method group 'GetType' to non-delegate type 'System.Type'. Did you intend to invoke the method? on this code line Type type = oFolderBrowserDialog.GetType;
namespace Deploy
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
{
FolderBrowserDialog objFolderDialog = new FolderBrowserDialog();
textBox1.Text = GetNetworkFolders(objFolderDialog);
}
foreach (string dirPath in Directory.GetDirectories(textBox1.Text, "*",
SearchOption.AllDirectories))
Directory.CreateDirectory(dirPath.Replace(textBox1.Text, textBox2.Text));
//Copy all the files & Replaces any files with the same name
foreach (string newPath in Directory.GetFiles(textBox1.Text, "*.*",
SearchOption.AllDirectories))
File.Copy(newPath, newPath.Replace(textBox1.Text, textBox2.Text), true);
}
public static string GetNetworkFolders(FolderBrowserDialog oFolderBrowserDialog)
{
Type type = oFolderBrowserDialog.GetType;
System.Reflection.FieldInfo fieldInfo = type.GetField("rootFolder", BindingFlags.NonPublic | BindingFlags.Instance);
fieldInfo.SetValue(oFolderBrowserDialog, (Environment.SpecialFolder)18);
if (oFolderBrowserDialog.ShowDialog() == DialogResult.OK)
{
return oFolderBrowserDialog.SelectedPath;
}
else
{
return "";
}
}
}
}
Just change this line
Type type = oFolderBrowserDialog.GetType();
^^^^^