I'm looking for some tips / suggestions for the best way to handle file imports. Essentially, I have two scenarios where files are imported and would like to have one unified solution for importing. The first scenario is that we get files dropped into an FTP folder that are PGP encrypted. During processing, I want to decrypt these in memory so as never to have an unencrypted file sitting on the server. The second scenario will be when a user uploads a file via the .NET FileUpload control. These files will NOT be encrypted. Natively, I can grab FileUpload.FileBytes to get a byte array of the data. I'm using a 3rd party library (File Helpers) to parse the file and import into the database. The File Helpers library will accept any of the following: file path, string, or stream (TextReader). In this case, I think the stream is the way to go.
Ultimately, my question is what is the best way to go from a byte array to TextReader? I am doing the following:
MemoryStream ms = new MemoryStream(FileBytes);
StreamReader strmReader = new StreamReader(ms);
FileBytes is a byte array taken from the FileUpload control. With the PGP files, I can decrypt that right into a MemoryStream so then I'll just toss that to a StreamReader and will be good.
Thanks for the help!
View Complete Post