1

When I'm trying to upload an .htm file to the server by selecting a file from dropdown list I am getting this exception. The details of the exception is given below

 System.IO.IOException was unhandled by user code
  Message=The device is not ready.

  Source=mscorlib
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at 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)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
       at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
       at System.IO.StreamReader..ctor(String path, Encoding encoding)
       at System.IO.File.InternalReadAllText(String path, Encoding encoding)
       at System.IO.File.ReadAllText(String path)
       at e_request.Report.DropDownList1_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\Administrator\Desktop\SmartUltrasoundPatientSchedulingSystem\trunk\code\e_request\e_request\Report_Writing.aspx.cs:line 107
       at System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
   at System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent()
   at System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
   at System.Web.UI.Page.RaiseChangedEvents()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


string Doc_content = File.ReadAllText("E:\\rajesh\\US_schedular\\template_htm\\" + DropDownList1.SelectedItem + ".htm"); 
Doc_content = Server.HtmlEncode(Doc_content); 
foreach (string parameter in details) 
{ 
    Doc_content = ReplaceText(Doc_content, variablenames[count], parameter);   
    count++; 
} 
CKEditor1.Text = Doc_content; 
Marco
  • 22,856
  • 9
  • 75
  • 124
  • Please show us your code. – Marco Mar 17 '15 at 08:21
  • string Doc_content = File.ReadAllText("E:\\rajesh\\US_schedular\\template_htm\\" + DropDownList1.SelectedItem + ".htm"); Doc_content = Server.HtmlEncode(Doc_content); foreach (string parameter in details) { Doc_content = ReplaceText(Doc_content, variablenames[count], parameter); count++; } CKEditor1.Text = Doc_content; – Rajesh Poojary Mar 17 '15 at 08:22
  • this code i m using....and at the very first line i m getting the exception – Rajesh Poojary Mar 17 '15 at 08:23

1 Answers1

0

I think you don't use this method for access the directory.

 Server.MapPath(...)

check this link1...

check this link2...

Community
  • 1
  • 1
Nalaka
  • 1,165
  • 7
  • 12