Asp.Net Hata Alıyorum
-
Arkadaşlar yaptığım projeyi publish edip ftpye attım iki yerde sıkıntıyla karşılaşıyorum 1. resim yüklerken hata alıyorum 2. hata logları tutuyorum onları oluşturacağı zaman da hata veriyor sebebi nedir acaba yardımcı olabilirmisiniz
Verdiği hata bu
Server Error in '/harun.aydin' Application.
Could not find a part of the path 'C:\Staj\Logs\log(17.05.2012_23.18.33).txt'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Staj\Logs\log(17.05.2012_23.18.33).txt'.
Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:[DirectoryNotFoundException: Could not find a part of the path 'C:\Staj\Logs\log(17.05.2012_23.18.33).txt'.] System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +224 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) +1142 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) +82 System.IO.StreamWriter.CreateFile(String path, Boolean append) +55 System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) +121 System.IO.StreamWriter..ctor(String path, Boolean append) +33 Library.HataLog.LogKayitEt() in c:\users\harun aydin\documents\visual studio 2010\projects\Library\Library\HataLog.cs:19 Library.KitapEkle.Btn_Yukle_Click(Object sender, EventArgs e) in c:\users\harun aydin\documents\visual studio 2010\projects\Library\Library\KitapEkle.aspx.cs:40 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
-
2. log path in local deki kalmis path i server kodlarilariyla olusturmalisin
1. dizin izinlerini kontrol et
-
StreamWriter str = new StreamWriter(HttpContext.Current.Server.MapPath("../Logs/log(" + tarih + "_" + zaman + ").txt"), true);
log tuttum yer bu kod nasıl localdeki kalıyoki elle tam bir dizin girmiyorum ki aslında
ResimUrl = "KitapResim/" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + FU_UrunResim.FileName;
FU_UrunResim.SaveAs(Server.MapPath("../") + ResimUrl);Bu da resim yüklediğim yer izinler 666 iki klasör için de ama nerde hata yapıyorum anlamadım localde sıkıntısız çalışıyor
-
up
-
../ bunu yazma.
KitapResim ve Logs klasörlerinin oluşturulmuş olmasına dikkat et.
edit şurada ne yapmaya çalıştın anlayamadım
log(" + tarih + "_" + zaman + ").txt")
-
NuLL29 bunu yazdı:
-----------------------------../ bunu yazma.
KitapResim ve Logs klasörlerinin oluşturulmuş olmasına dikkat et.
edit şurada ne yapmaya çalıştın anlayamadım
log(" + tarih + "_" + zaman + ").txt")
-----------------------------../ iki türlü de denedim bi sonuca ulaşamadım Klasörler de en baştan beri oluşturulmuş şekilde deniorum.
log(" + tarih + "_" + zaman + ").txt") burada log dosyasının ismini tarih_zaman şeklinde oluşmasını sağlıyorum.
-
(" ") bunları neden yazdın? Şöyle yap
StreamWriter str = new StreamWriter(HttpContext.Current.Server.MapPath("~/Logs/log " + tarih + "_" + zaman + ".txt"), true);
FU_UrunResim.SaveAs(Server.MapPath("~/" + ResimUrl);
../ yerine ~/ kullan
-
NuLL29 bunu yazdı:
-----------------------------(" ") bunları neden yazdın? Şöyle yap
StreamWriter str = new StreamWriter(HttpContext.Current.Server.MapPath("~/Logs/log " + tarih + "_" + zaman + ".txt"), true);
FU_UrunResim.SaveAs(Server.MapPath("~/" + ResimUrl);
../ yerine ~/ kullan
-----------------------------
Çok saolsın hocam ../ yerine ~/ koyunca düzeldi bütün sorunlar -
kolay gelsin;)
