string path =Server.MapPath("exercise.txt");
FileStream fs;
if( !File.Exists(path))
{
fs= new FileStream(path ,FileMode.Create,FileAccess.Write,FileShare.None);
}StreamWriter sw = new StreamWriter(path,false,Encoding.Default);
sw.Flush();
sw.Close();
fs=null;
FileStream fs;
if( !File.Exists(path))
{
fs= new FileStream(path ,FileMode.Create,FileAccess.Write,FileShare.None);
}StreamWriter sw = new StreamWriter(path,false,Encoding.Default);
sw.Flush();
sw.Close();
fs=null;
try
{
fs = new FileStream(fullFileName,FileMode.Create,FileAccess.Write);
StreamWriter sw = new StreamWriter(fs,Encoding.Default);
sw.Write(fileContent);
sw.Close();
}
finally
{
if(fs != null)
fs.Close();
}
using (StreamWriter sw = new StreamWriter(FS))
{
sw.Write("This is the ");
}
Response.Write(path+"<br>");
if( !File.Exists(path))
{
File.Create(path);
}
StreamWriter sw = File.OpenWrite(); //注意此行.
sw.Write("yes");
sw.Close();
{
if(fs != null)
fs.Close();
}