I have a folder that contains x amount of files with different extensions, I need a way to retrieve all the files with the name 0000001 regardless of their extension, i then have to work with these and then retrieve all files with the name 0000002. I know I can increment the filename variable but when the file name becomes 0000010 how do I keep it the same amount of digits when incrementing, will it just add an extra digit such as 00000010.
So far I am accessing the files and saving them all in an array
String[] files = Directory.GetFiles(@"D:\test\ElectionFiles");
and then looping through each file and pulling the information from it and sending it to the database
foreach (String fi in files)
{
FileInfo f = new FileInfo(fi);
string filename = f.Name;
XmlDocument doc = new XmlDocument();
doc.Load(fi);
string document = doc.InnerXml;
SqlCommand cmd = new SqlCommand("submit");
cmd.Parameters.AddWithValue("@document", document);
cmd.Parameters.AddWithValue("@filename", filename);
cmd.Parameters.Add(new SqlParameter()
{
ParameterName = "RETURN_VALUE",
Direction = ParameterDirection.ReturnValue
});
}
Just want some advice if this looks correct and how I can go about only retrieving the 4 files at a time and how I can increment the filename to retrieve the correct files.
Thanks