PDA

View Full Version : سوال: اشکال در مورد کار با فایل ها



hajbhenam
پنج شنبه 28 آذر 1392, 09:09 صبح
سلام
کجای کدم اشتباهه که فایل رو ایجاد نمیکنه در صورتی که کد اجرا میشه


string pass = txt_pass.Text;
string passhash = MD5Hash(pass);
string path = Server.MapPath(".");
StreamWriter file = new StreamWriter(path+"log.txt");

file.WriteLine(passhash);
file.Close();

txt_pass.Text = "";

fakhravari
پنج شنبه 28 آذر 1392, 10:33 صبح
http://msdn.microsoft.com/en-us/library/system.io.file.createtext(v=vs.110).aspx
try
{
StreamWriter sw = File.CreateText(MapPath("test.txt"));
sw.WriteLine(txtFile.Text);
sw.Close();
}
catch (IOException ex)
{
lblStatus.Text += ex.Message;
}