Click here to Skip to main content
15,849,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

i need help,

whenever i run my site i receive the error msg like System.IO.IOException: The device is not ready

code
====
C#
private Log()
       {
           if (AppConfigs.IsLogEnabled)
           {
               if (WebLog == null)
               {
                   engine = new CommonEngine();

                   string appPath = string.Empty;
                   if (!string.IsNullOrEmpty(AppConfigs.LogPath))
                       appPath = AppConfigs.LogPath;
                   else
                       appPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "logs");

                   DirectoryInfo di = new DirectoryInfo(appPath);
                   if (!di.Exists)
                       di.Create();

                   string fileName = AppConfigs.ApplicationName + "_" + engine.GetDateSuffix("") + ".log";

                   FileInfo fi = new FileInfo(Path.Combine(appPath, fileName));

                   if (fi.Exists)
                       tw = File.AppendText(fi.FullName);
                   else
                       tw = new StreamWriter(fi.FullName);

                   sb = new StringBuilder();
                   HasError = false;

               }

           }
       }


error coming di.Create(); this line, can anybody pls help what i need to do for this issue.

thanks
renga
Posted

1 solution

It's not a good idea to try and store data in your application folder, or any subdirectory: in production these are normally write protected to reduce virus activity.

Have a look here: Where should I store my data?[^] - it suggests some "safer" places which should always be available.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900