PDA

View Full Version : خطای the process can not access the file



mona_z
پنج شنبه 30 خرداد 1387, 21:12 عصر
با سلام
این کد رو برای ذخیره عکس در پایگاه داده نوشتم ولی روی خطی که مشخص کردم خطا می ده.
string currentPath = Application.StartupPath;
string a= currentPath + namepic;
FileStream fs = new FileStream(a, FileMode.Open);*
FileInfo fi = new FileInfo(currentPath + namepic);
byte[] swf = new byte[(int)fi.Length];
fs.Read(swf, 0, (int)fi.Length);
sqlcon.Open();
sqlcom.CommandText = "Insert into images (nationalCode,image) Values (@nationalCode,@image)";
sqlcom.Parameters.Add("@nationalCode", SqlDbType.BigInt).Value = txtnationalCode.Text;
sqlcom.Parameters.Add("@image", SqlDbType.Image).Value = swf;
sqlcom.ExecuteNonQuery();
sqlcon.Close();

aliaaa
جمعه 31 خرداد 1387, 10:48 صبح
این اشکال توی ویندوز ویستا ایجاد میشه چون (مثلا) امنیت ویستا رو بالا بردند این اشکال میده
بهتره با Administrator بیای بالا و برنامه تو بنویسی.

اگه کسی راه حلی پیدا کرد بگه.