• Log in or sign up for an account here: https://www.sythe.org/login

Using StreamWriter

ScubaSteve7

Member
Joined
Dec 1, 2010
Sythe Gold
0
Messages
35
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?
 
Pretty much screwed
 
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?

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..
 
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..


Can't delete because it says file is in use by another operation.
 
using (streamwriter sw=new streamwriter())
{}

the streamwriter should be close
 
Runescape Gamblingrunescape gambling
Back
Top