I'm not exactly sure what's going on here--I tried to debug but couldn't really come up with any explanation as to why nothing is being written to my datagridview.
Anybody have any idea?
public partial class CleanPathResults : Form
{
public CleanPathResults()
{
InitializeComponent();
}
public void RenameFolder(string folderName)
{
string regPattern = (@"[~#&$!%+{}]+");
string replacement = "";
List<string> normal = new List<string>();
Regex regExPattern = new Regex(regPattern);
dataGridView1.Rows.Clear();
List<string> cleanDirNames = new List<string>();
try
{
if (regExPattern.IsMatch(folderName))
{
string cleanup = regExPattern.Replace(folderName, replacement);
System.IO.Directory.Move(folderName, cleanup);
DataGridViewRow grid = new DataGridViewRow();
grid.CreateCells(dataGridView1);
grid.Cells[0].Value = folderName;
grid.Cells[1].Value = cleanup;
dataGridView1.Rows.Add(grid);
folderName = cleanup;
cleanDirNames.Add(cleanup);
}
else
{
normal.Add(folderName);
}
}
catch(Exception e)
{
throw;
}
DirectoryInfo di = new DirectoryInfo(folderName);
DirectoryInfo[] diArr = di.GetDirectories();
List<string> subdirectories = new List<string>();
try
{
foreach (DirectoryInfo subdir in diArr)
{
subdirectories.Add(subdir.ToString());
}
}
catch(Exception e)
{
throw;
}
try
{
foreach (string folder in subdirectories)
{
string sF = folder;
RenameFolder(folderName + "\\" + sF);
}
}
catch(Exception e)
{
throw;
}
}
private void button1_Click_1(object sender, EventArgs e)
{
Application.Exit();
}
}
I'm not hitting any errors--the app does what it's supposed to do (in this case, make sure folder names do not contain the invalid chars defined in the regex)...however it's just an issue of output not displaying on the dgv.
Any help would be appreciated.