Excel file path is in server folder i need to read from there and update in sql
now data is reading from my local path and updating in sql
but i need to change local path to server path for reading and once it is updated in sql then it should move to another folder (like filename is read folder) using console C# application i'm working on it
Please help me on this

Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 21, 2023, 8:15 AM EDT
Try below solution.
Define the source folder path (local folder path or server folder path) and the destination archive folder path.
string sourceFolderPath = @"\\servername\foldername"; string archiveFolderPath = @"\\servername\archivefoldername";Use the System.IO namespace to get the files from the source folder path.
string[] filePaths = Directory.GetFiles(sourceFolderPath);Loop through the file paths and perfrom your import logic
Once the data is imported, use the File.Move method to move the file to the archive folder. bulk copy method to import the data from the Excel file to SQL.
foreach (string filePath in filePaths) { string fileName = Path.GetFileName(filePath); string destinationPath = Path.Combine(archiveFolderPath, fileName); File.Move(filePath, destinationPath); }Thanks
Naimish