#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    4
    Rep Power
    0

    Arrow A little direction


    Hello all.

    Well is what im wanting to do is attempt to write a program in C# that take a .txt doc and add your desired string or character at the beginning or end or both. I have no idea where to even start so I was hoping someone could shed some light on this for me.

    Also while im at it, is it possible to take 2 separate .txt docs..lets say one is filled with the names of documents and the other is filled with links to the document, can you join them together, while placing lets say html or css(doesn't matter just string in general) code/tags at the beggining of the line, in between the title's and links of the documents and at the end also?

    thanks in advance for any input
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,255
    Rep Power
    2222
    Inserting, deleting, or modifying the contents of a text file pretty much follows this basic procedure:
    1. Open two files, the text file as the input for reading, and a new temporary file for output to write to.

    2. Read the input file, line by line, and write it to the output file, doing whatever else you need to do:
    a. If you need to insert something before that line, then write it to the output file before you write that line you input.
    or
    b. If you need to delete that line, then do not write it out to the output file.
    or
    c. If you need to modify that line, then modify it and then write it to the output file.

    3. When you are done, then close both files, delete the input file, and rename the temporary output file to the input file's old name.

    And that's how you do it.

    Also while im at it, is it possible to take 2 separate .txt docs..lets say one is filled with the names of documents and the other is filled with links to the document, can you join them together, while placing lets say html or css(doesn't matter just string in general) code/tags at the beggining of the line, in between the title's and links of the documents and at the end also?
    Yes, of course it's possible. That is exactly how we used to generate dynamic web pages with CGI (Common Gateway Interface).

    You know how to write text files and you know how to read text files, so you just need to incorporate what you read with what you're writing. Could possibly get a bit tedious, but entirely doable.
  4. #3
  5. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,555
    Rep Power
    2338
    More like "A little forum spamming"

    From this well-known page (note: you might want to read the entire thing):

    You are likely to be ignored, or written off as a loser, if you:
    ...
    cross-post to too many different newsgroups
    ...
    substitute forums for newsgroups there.

    Also
    Don't shotgun-blast all the available help channels at once, that's like yelling and irritates people. Step through them softly.
    And
    Resist the temptation to close your request for help with semantically-null questions like “Can anyone help me?” or “Is there an answer?” First: if you've written your problem description halfway competently, such tacked-on questions are at best superfluous. Second: because they are superfluous, hackers find them annoying — and are likely to return logically impeccable but dismissive answers like “Yes, you can be helped” and “No, there is no help for you.”

    In general, asking yes-or-no questions is a good thing to avoid unless you want a yes-or-no answer.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    4
    Rep Power
    0
    thanks for the input, i found out streamwriter and Filestream are something i need to look at.

    And i posted on other communities because there are great people at other ones as well and I like to look at all the different answers..I get to see it at different angles. didnt mean to cause you such an inconvenience

IMN logo majestic logo threadwatch logo seochat tools logo