i am designing a web applicatin in dotnet using c#. i have listed out the all the excel files and i am converting excel files to text files to search the content the entire file.
but previously it worked without error but now i am getting ther process is working with another process.
The coding i am displaying here :
Excel.Application lobj=new Excel.Applcaiton();
try
{
DirectoryInfo dir = new DirectoryInfo(Request.PhysicalApplicationPath + “/all files”);
FileInfo[] fi = dir.GetFiles(“*.xls”);
//FileStream fileStream;
StreamReader streamReader;
string line;
foreach (FileInfo fil in fi)
{
excelobj = new Excel.Application();
// ( openFileDialog1.FileName, 0, true, 5,””, “”, true, Excel.XlPlatform.xlWindows, “\t”, false, false,0, true);
Excel.Workbook wkb = excelobj.Workbooks.Open(AppDomain.CurrentDomain.BaseDirectory + “/all files/” + fil.Name, 0, true, 5, “”, “”, true, Excel.XlPlatform.xlWindows, “\t”, false, false, 0,true ,false,false);
// Excel.Sheets sheets = wkb.Worksheets;
//Excel.Worksheet ws = (Excel.Worksheet)wkb.ActiveSheet;
string fname1 = fil.Name;
int pos = fname1.IndexOf(“.”);
string fname2 = fname1.Substring(0, pos);
excelobj.ActiveWorkbook.SaveAs(“c:\\” + fname2 + “.txt”, Excel.XlFileFormat.xlCSVWindows, Type.Missing, Type.Missing,Type .Missing , Type.Missing, Excel.XlSaveAsAccessMode.xlShared, Type.Missing, Type.Missing, false, 1, 0);
excelobj.Quit();
//Excel.XlSaveAsAccessMode.xlShared
streamReader = new StreamReader(“c:\\” + fname2 + “.txt”);
while (streamReader.Peek() != -1)
{
line = streamReader.ReadLine();
if (line == TextBox2.Text)
{
Label2.Text = “found”;
ListBox1.Items.Add(fil.Name);
break;
}//IF
}//WHILE
streamReader.Close();
}//FOR EACH
} //TRY
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
}
please help me.