1. I am trying to dynamically create a text file. The problem is that 99% of the file is static every time, and the 1% needs to be dynamically generated. So I decided to split the file into the static and dynamic part, which I have successfully done: the dynamic part generates correctly so that is great. Now I need to append the rest of the file to the dynamic part. The only problem is that the static part is in excess of 50MB, so I really don't want to read the whole thing in before appending it. Any ideas on how I could do it?
2. Are there any copy/delete functions available through ASP.NET? Ideally I would like to create the file locally and then copy it to another server programmatically.
Thanks for your helpUse this static method:
System.IO.File.Copy
Thanks, I believe that will work for the second part of my question, any ideas on the first part?
Copy the static file then open the new file for append and add the dynamic part.
50 Megs is a lot!!, so careful there.
Yeah that's what I was hoping to avoid, because I'm afraid it's going to either time out the server, and regardless, take forever. I know with DOS you can do "copy file1.txt+file2.txt newfile.txt" which basically appends file2 to file1 and puts it into newfile. I'm just curious if System.IO.Copy basically works the same way as the DOS copy.
A quick question for you. How does that process work?, what triggers the creation of such files?, does it have to be "Real time" ?
The reason why I'm asking is because if you could queue the requests to create these files then you could have control over how and when these files are created.
For example, you could create a table in SQL Server (or use MSMQ) and store the dynamic part in a record, then you could have a Windows Service with a timer that runs every N minutes/hours or whatever and process each "pending" request one at the time. This windows service can be located on a different server (not the web server) so you don't impact the performance of your web app.
That is just an idea, I can expand on it if you want.
The way the process is set up now, the user will fill out the web form which creates the dynamic portion of the file. I think you have a good idea there... could you explain a little more about what kind of windows service you would use and/or how I would implement it? The only thing i'm really familiar with for scheduling is the basic windows task scheduler. Thanks.
Well. A Windows Service is a type of project in .NET and is used to create Window Services (applications that run as a service in the OS and they (normally) don't have a user interface) and can run impersonating a user account or as the local system account). Services don't require a user to be logged on into the OS in order to run. They run just as the OS starts.
They are very easy to code and install and there are a whole lot of samples out there.
Thanks for all your time. I will look into it further.
0 comments:
Post a Comment