باسلام
یه برنامه نوشتم که درست اجرا می شد،یه کپی از برنامه رو هم روی حافظه فلشم ریختم،ولی چند روزی که برنامه ای که رو ی سیستممه موقع اجرا این Error رو میده،در صورتی که برنامه ی روی حافظه فلشم هنوز درست اجرا میشه،
System.IO.IOException:The process cannot a access the file//...path Directory....\\ because it is being used by another process
اینم تابع مربوط به این Error:
private void SetPictures(PictureBox picture, Label lable,int index)
{
byte[] barrImg = (byte[])DT.Rows[index]["Picture"];
//
string strfn = Convert.ToString(DateTime.Now.ToFileTime());
FileStream fs = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write);
fs.Write(barrImg, 0, barrImg.Length);
fs.Flush();
fs.Close();
//
picture.Image = Image.FromFile(strfn);
lable.Text = DT.Rows[index]["Name"].ToString();
}
دلیل این جور اشکالات که گه گاه در کدنویسی پیش میاد چیه و چطور میشه حلشون کرد که دیگه این اشکالات در برنامه تکرار نشه؟؟؟