Using StreamWriter

Discussion in 'Programming General' started by ScubaSteve7, Mar 5, 2011.

Using StreamWriter
  1. Unread #1 - Mar 5, 2011 at 10:34 PM
  2. ScubaSteve7
    Joined:
    Dec 1, 2010
    Posts:
    35
    Referrals:
    0
    Sythe Gold:
    0

    ScubaSteve7 Member

    Using StreamWriter

    I don't feel showing my code is necessary, so here's the idea.
    I create a StreamWriter, write to a the file, close it, email it, then erase it using File.WriteAll(path, "").
    The problem is that i'm trying to do this using a loop, and I can't use the StreamWriter again in the loop because I have closed it. Is there a way to reopen it? or what other options are there?
     
  3. Unread #2 - Mar 5, 2011 at 11:07 PM
  4. Rs Trades
    Joined:
    Mar 5, 2011
    Posts:
    33
    Referrals:
    0
    Sythe Gold:
    0

    Rs Trades Member
    Banned

    Using StreamWriter

    Pretty much screwed
     
  5. Unread #3 - Mar 23, 2011 at 7:55 PM
  6. Jeezal
    Joined:
    Mar 23, 2011
    Posts:
    285
    Referrals:
    0
    Sythe Gold:
    0

    Jeezal Forum Addict

    Using StreamWriter

    thats a bit f up
     
  7. Unread #4 - Mar 26, 2011 at 5:42 PM
  8. Puffo
    Joined:
    Jun 3, 2007
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0

    Puffo Member

    Using StreamWriter

    for(int i = 0;i > MyLoop;i++)
    {
    StreamWriter sw = new StreamWriter("myfile.txt");
    sw.write("lol");
    sw.Close();
    E-mail();
    if(Exists("myfile.txt"))
    {
    File.Delete("myfile.txt");
    }
    }

    Thats how i whould do it..
     
  9. Unread #5 - Mar 30, 2011 at 4:10 PM
  10. ScubaSteve7
    Joined:
    Dec 1, 2010
    Posts:
    35
    Referrals:
    0
    Sythe Gold:
    0

    ScubaSteve7 Member

    Using StreamWriter


    Can't delete because it says file is in use by another operation.
     
  11. Unread #6 - Apr 5, 2011 at 10:23 AM
  12. Puffo
    Joined:
    Jun 3, 2007
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0

    Puffo Member

    Using StreamWriter

    sw.Dispose();
     
  13. Unread #7 - Nov 18, 2011 at 11:50 AM
  14. MonsterMMORPG
    Joined:
    Nov 18, 2011
    Posts:
    169
    Referrals:
    0
    Sythe Gold:
    25

    MonsterMMORPG Active Member

    Using StreamWriter

    be sure that you are using this

    using () {}

    or close streamwriter yourself
     
  15. Unread #8 - Mar 29, 2012 at 3:19 AM
  16. AAASeller
    Joined:
    Mar 29, 2012
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0

    AAASeller Newcomer

    Using StreamWriter

    using (streamwriter sw=new streamwriter())
    {}

    the streamwriter should be close
     
  17. Unread #9 - Apr 16, 2012 at 12:00 AM
  18. dongchan
    Joined:
    Apr 15, 2012
    Posts:
    82
    Referrals:
    0
    Sythe Gold:
    0

    dongchan Member

    Using StreamWriter

    dispose it
     
< C# Project | Looking for tutorials. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site