I do not think it's the best solution to process a file already uploaded. Ideally, you should just move the file to a folder on your server and have a service do the processing for you.
This prevents you from crashing your application on the ISS and the Database doing very heavy processing, and takes away that responsibility from your WebSite or WinForms to do what it would not really be your responsibility to make future maintenance on a code that probably is complex.
There is no way I can suggest an implementation of how to save the file since I do not know if you use MVC, Web Forms or Win Forms.
But in the case of Windows Service you need to use a File System Watcher Type object to monitor the receipt of files in the server folder as the example:
public partial class ProcessadorDeArquivo
{
protected FileSystemWatcher _fileSystemWatcher { get; set; }
public ProcessadorDeArquivo()
{
_fileSystemWatcher = new FileSystemWatcher(@"C:\Arquivos"); //Pasta que será utilizada para salva os arquivos.
_fileSystemWatcher.Filter = ".txt" //ExtensãoDoArquivo
_fileSystemWatcher.Created += FileSystemWatcherCreated;
_fileSystemWatcher.EnableRaisingEvents = true;
}
/// <summary>
/// Quando um arquivo é criado na pasta assistida esse evento é disparado
/// </summary>
protected void FileSystemWatcherCreated(object sender, FileSystemEventArgs e)
{
ProcessarArquivos(e.FullPath); //Método que teria toda a regra de processar.
}
}
EDIT (ASP.NET MVC)
//VIEW
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { enctype ="multipart/form- data" }))
{
<input type="arquivo" name="arquivo" />
<input type="submit" value="salvar" />
}
//CONTROLLER
public ActionResult Index(HttpPostedFileBase arquivo)
{
// Verify that the user selected a file
if (arquivo != null)
{
var nome = Path.GetFileName(arquivo.FileName);
arquivo.SaveAs(@"C:\Arquivos\" + nome);
}
return View();
}