//copy database files to target directory
            string fileName = "test.txt";
            string targetPath = StaticFormInstances.choose.txtbxTargetDir.Text;
            string sourcePath = @"\\il93fil48\3GSM\release\testapplication_REL_01_00_09\database";

            //Use Path Class to manipulate file and directory paths
            string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
            string destFile = System.IO.Path.Combine(targetPath, fileName);

            //Create a new target folder if it doesn't exist
            if (!System.IO.Directory.Exists(targetPath))
            {
                System.IO.Directory.CreateDirectory(targetPath);
            }

            if (System.IO.Directory.Exists(sourcePath))
            {
                string[] files = System.IO.Directory.GetFiles(sourcePath);

                //calculate total number of files in source
                int totalNumberOfFiles = files.Length;

                //current file number
                int fileNumber = 0;

                //create object to store database string
                OdbcConnectionStringBuilder builder = new OdbcConnectionStringBuilder();

                foreach (string s in files)
                {
                    //increase file number by 1
                    fileNumber++;

                    //copy file based on fileNumber
                    fileName = System.IO.Path.GetFileName(s);
                    destFile = System.IO.Path.Combine(targetPath, fileName);
                    System.IO.File.Copy(s, destFile, false);
                    
                    //set up database
                    
                    builder.Driver = "Microsoft Access Driver (*.mdb)";
                    builder.Dsn = fileName.Substring(0,fileName.Length - 4);
                    builder["Description"] = fileName.Substring(0, fileName.Length - 4);
                    builder["DBQ"] = destFile;
                    Console.WriteLine(builder.ConnectionString);
                    Console.WriteLine();

                    //clear current values and reset know keys to default
                    builder.Clear();

                    //calculate progess out of base of 100
                    int ProgressPercentage = (fileNumber / totalNumberOfFiles) * 100;

                    //update the progress bar
                    bckgrdSetUpDatabases.ReportProgress(ProgressPercentage);
                }
                
            }

Updated code

Following error: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

//set up database
                    OdbcConnectionStringBuilder builder = new OdbcConnectionStringBuilder();

                    builder.Driver = "Microsoft Access Driver (*.mdb)"; 
                    builder.Dsn = fileName.Substring(0, fileName.Length - 4); 
                    builder["Description"] = fileName.Substring(0, fileName.Length - 4); 
                    builder["DBQ"] = destFile;


                    System.Data.Odbc.OdbcConnection conn = new OdbcConnection(builder.ToString());

                    try
                    {
                        conn.Open();
                        // Process data here.
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to connect to data source" + ex);
                    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.