A stream of questions from a C# newcomer

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi everybody.
{hi, dr Nick}
Im brand new to C# and OOP altogether, although Ive had some experience with the more scriptish approaches to programming like AutoIt and mIRC routines, so Im familiar with the overall principles {i.e. when talking to a computer, use very, very small
words}.
Im also gradually working through the VS2010 Step By Step book - well, not so gradually, actually, considering Ive gone through over the first hundred-or-so pages yesterday, but Ive realized that, now that I have most of the basic concepts down {I believe,
my brain fried at constructors}, I might try to put that learning to practical use - especially as practicing towards a solution would help cement the principles Ive grasped.
Of course, theres a lot that I still need to learn, which is where this thread comes in - with your permission, Ill throw various questions about the steps I believe I need to take to rebuild this program from the ground up {I did it once before, but in
one of the scripty languages mentioned earlier} and if anyone can explain how or, for that matter, why it should be done differently, Id be appreciative. Keep in mind, most of these will likely be blisteringly simple for an experienced programmer - Ive just
left the starting line.
So, with that in mind - the project overview.
Goal: Take a group of files from a networked drive and sort them into separate files according to the department they need to go before printing them.
Game plan:
<ol>
Read the list of files to be processed from an ini file or something similarly editableCopy said files to a local path for processing and backup, emptying said path beforehandOpen each file in turn and split it into an array of X-line pages. The files are essentially plaintext, bypassing the need for formatting.On each element of the array, search for the department number. The naming convention varies, thus parsing information for each file needs to be stored in the ini as well.Append each page to its respective collated department file.Once all files are processed, send each of the department files to a set network printer via a downlevel print job.</ol>
The hitches:
<ol>
How do I pull up and/or enter information into an ini? I havent found any methods in the MSDN library that seem to deal with standard ini files.The file names arent static, following a Filename+year+day-of-year.txt naming convention. While I can get the list of files with a Directory.GetFiles method, how do I pull up the first/last X characters from a string? The String class doesnt seem to have
anything along those lines.While I can split the file line-by-line with the String.Split or File.ReadAllLines methods, this would split it by each line, instead of page-sized blocks. What would be the best way to handle this? Given that each file has a {mostly} fixed header, maybe
try regexes? How can I find the position of a substring within a string? I.e., if I want to take advantage of the "DepartmentPrefix DepartmentNumber" convention within the files. On a related note, how to I pull up a substring within a string with an offset {i.e. "give
me sixth through tenth characters in this string}No problems here... theoretically.Would File.Copy work?</ol>
And thats it for this particular project, or at least the basics of it - odds are Ill keep asking about clarifications, possible alternative methods and so on and so forth - its a learning experience. Also, for a more "Ill be making it up as I go along"
project - what method could I use to download {whether into memory or directly save to disk} a web page? Or, for that matter, to retrieve its size without downloading?

Thanks to everyone in advance,

Quinch

View the full article
 
Back
Top