Hello,
I'm newer to programming and trying to do something that has me stumped. I need to read files from a directory on a server and compare those file names to a field in a database. When I find the file names that are the same, grab a different field which is actually a path to the server and see if the file exists there. If not, copy the file to that location. I've been working on this for quite some time, I have not started working on copying the files so I sort of want to try to figure that out on my own. But I need help in comparing the files, here is what I have so far...
namespace MissingImages
{
public partial class frmImages : Form
{
public frmImages()
{
InitializeComponent();
}
private void btnGetDirFiles_Click(object sender, EventArgs e)
{
DirectoryInfo dirCustom = new DirectoryInfo("\\\\disk2\\images\\Missing Images");
FileInfo[] filCustom;
filCustom = dirCustom.GetFiles();
}
private void btnOBJTable_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand();
{
frmImages rd = new frmImages();
rd.SimpleRead();
}
}
public void SimpleRead()
{
SqlDataReader rdr = null;
SqlConnection conn = new SqlConnection( "Server=TSQLTVS;UID=notreal;PWD=alsonotreal;Database=Flowtiva");
SqlCommand cmd = new SqlCommand("select FILENAME, SOID from obj", conn);
conn.Open();
rdr = cmd.ExecuteReader();
}
}
}
This does appear as I step through it to pull the information from both places. The SOID field in the obj table of the database is just a string with the server path in it.
Can anyone help or at least point me in the right direction?
Thanks in advance