Hi All,
I am generating temporary xml files to bind it to tree view control.
A unique xml file is generated for each user. I generating these files
Using streamwriter class. Later when I try to delete the file with
File.Dlete in page unload event I gets an error File already in use by
another process. When I examine process explorer aspnet_wp.exe is hold
these files.
Here is the code I am working on.. Any advise please.
Thanks in advance
Rao
private void Page_UnLoad(object sender, System.EventArgs e)
{
try
{
if (File.Exists(Server.MapPath(xmlDocPath+ProjectsDoc )))
{ ProjectTree.Dispose();
File.Delete(Server.MapPath(xmlDocPath+ProjectsDoc) );
}
}
catch(Exception ex)
{SetErrorMessage(ex.Message.ToString(),true);
}
}
private void InitializeTreeView()
{
//Add data to treeview based on the projectXML stored procedure
//ProjectTree.TreeNodeSrc=
DataRetrieval.formatXMLforTree("eacollin.ProjectXM L");
ProjectsDoc=DataRetrieval.PrepareProjectsXMLdoc("e acollin.ProjectXML");
ProjectTree.TreeNodeSrc= Server.MapPath(xmlDocPath+ProjectsDoc);
ProjectTree.DefaultStyle.CssText="color: black;font-family:
verdana;font-size: 8pt;";
ProjectTree.DataBind();
ProjectTree.Dispose();
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.Unload+=new System.EventHandler(this.Page_UnLoad);
//ProjectTree.Unload+=new System.EventHandler(this.DeleteXmlFiles);
}
public static string PrepareProjectsXMLdoc(string SPname)
{
// added by rao 8/27/2004
// added projects cache to avoid round trip to sql server, and
// additional processing involved in process returned xml from
// stored procedure
string strXML;
strXML="";
DataSet ds=new DataSet();
string OutFileName="";
System.IO.StringWriter strWriter = new StringWriter();
try
{
if(System.Web.HttpContext.Current.Cache["Projects"]==null)
{
ds = SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings[ASPNET.StarterKit.TimeTracker.Web.Global.CfgKeyCon nString],
SPname);
strXML = "";
ds.WriteXml(strWriter);
strXML = strWriter.ToString();
//get rid of the text version of < and > tags
strXML = Regex.Replace(strXML, "<", "<");
strXML = Regex.Replace(strXML, ">", ">");
//get ride of the XML headers
string search =
@"</XML_F52E2B61-18A1-11d1-B105-00805F49916B>\s*</Table>\s*<Table>\s*<XML_F52E2B61-18A1-11d1-B105-00805F49916B>";
strXML = Regex.Replace(strXML,search,"");
//Get rid of apostrophes which do not show up properly on the
webpage
strXML = Regex.Replace(strXML,"&apos;","'");
//find the part of the xml that starts and ends with TREENODES
int firstoccurance = strXML.IndexOf("TREENODES");
int secondoccurance =
strXML.IndexOf("TREENODES",firstoccurance+1);
int delta = secondoccurance - firstoccurance;
strXML = strXML.Substring(firstoccurance,delta);
strXML = "<" + strXML + "TREENODES>";
ds.Dispose();
// generate uniqe filename for each user
lock(System.Web.HttpContext.Current.Cache)
{
System.Web.HttpContext.Current.Cache.Insert("Proje cts",strXML,null,
DateTime.Now.AddHours(HoursLeft),Cache.NoSlidingEx piration);
}
}
else
{
strXML =(string)System.Web.HttpContext.Current.Cache["Projects"];
}
string NewGuid = System.Guid.NewGuid().ToString();
OutFileName=NewGuid+"_Projects.xml";
using(StreamWriter wr = new
StreamWriter(System.Web.HttpContext.Current.Server .MapPath(xmlDocPath+OutFileName)))
{
wr.Write(strXML);
}
strWriter.Close();
//return OutFileName;
}
catch(Exception ex)
{
System.Web.HttpContext.Current.Response.Write(ex.M essage);
}
return OutFileName;
} 3 2910
Is it possible for the treeview control to take something else other then a
file path? You really would want to avoid writing and deleting files for
each user
"rao" <ja********@hotmail.com> wrote in message
news:f2************************@posting.google.com ... Hi All,
I am generating temporary xml files to bind it to tree view control. A unique xml file is generated for each user. I generating these files Using streamwriter class. Later when I try to delete the file with File.Dlete in page unload event I gets an error File already in use by another process. When I examine process explorer aspnet_wp.exe is hold these files. Here is the code I am working on.. Any advise please.
Thanks in advance Rao
private void Page_UnLoad(object sender, System.EventArgs e) { try { if (File.Exists(Server.MapPath(xmlDocPath+ProjectsDoc ))) { ProjectTree.Dispose(); File.Delete(Server.MapPath(xmlDocPath+ProjectsDoc) ); }
} catch(Exception ex) {SetErrorMessage(ex.Message.ToString(),true); } }
private void InitializeTreeView() { //Add data to treeview based on the projectXML stored procedure //ProjectTree.TreeNodeSrc= DataRetrieval.formatXMLforTree("eacollin.ProjectXM L");
ProjectsDoc=DataRetrieval.PrepareProjectsXMLdoc("e acollin.ProjectXML"); ProjectTree.TreeNodeSrc= Server.MapPath(xmlDocPath+ProjectsDoc); ProjectTree.DefaultStyle.CssText="color: black;font-family: verdana;font-size: 8pt;"; ProjectTree.DataBind(); ProjectTree.Dispose(); }
private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); this.Unload+=new System.EventHandler(this.Page_UnLoad); //ProjectTree.Unload+=new System.EventHandler(this.DeleteXmlFiles);
} public static string PrepareProjectsXMLdoc(string SPname) { // added by rao 8/27/2004 // added projects cache to avoid round trip to sql server, and // additional processing involved in process returned xml from // stored procedure string strXML; strXML=""; DataSet ds=new DataSet(); string OutFileName=""; System.IO.StringWriter strWriter = new StringWriter(); try {
if(System.Web.HttpContext.Current.Cache["Projects"]==null) {
ds =
SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings[ASPNET.StarterKit
..TimeTracker.Web.Global.CfgKeyConnString], SPname);
strXML = ""; ds.WriteXml(strWriter); strXML = strWriter.ToString();
//get rid of the text version of < and > tags strXML = Regex.Replace(strXML, "<", "<"); strXML = Regex.Replace(strXML, ">", ">");
//get ride of the XML headers string search =
@"</XML_F52E2B61-18A1-11d1-B105-00805F49916B>\s*</Table>\s*<Table>\s*<XML_F5
2E2B61-18A1-11d1-B105-00805F49916B>"; strXML = Regex.Replace(strXML,search,"");
//Get rid of apostrophes which do not show up properly on the webpage strXML = Regex.Replace(strXML,"&apos;","'");
//find the part of the xml that starts and ends with TREENODES int firstoccurance = strXML.IndexOf("TREENODES"); int secondoccurance = strXML.IndexOf("TREENODES",firstoccurance+1); int delta = secondoccurance - firstoccurance; strXML = strXML.Substring(firstoccurance,delta); strXML = "<" + strXML + "TREENODES>"; ds.Dispose();
// generate uniqe filename for each user lock(System.Web.HttpContext.Current.Cache) {
System.Web.HttpContext.Current.Cache.Insert("Proje cts",strXML,null, DateTime.Now.AddHours(HoursLeft),Cache.NoSlidingEx piration); }
} else { strXML =(string)System.Web.HttpContext.Current.Cache["Projects"];
} string NewGuid = System.Guid.NewGuid().ToString(); OutFileName=NewGuid+"_Projects.xml";
using(StreamWriter wr = new
StreamWriter(System.Web.HttpContext.Current.Server .MapPath(xmlDocPath+OutFil
eName))) { wr.Write(strXML); }
strWriter.Close();
//return OutFileName; } catch(Exception ex) { System.Web.HttpContext.Current.Response.Write(ex.M essage); } return OutFileName; }
Hi Marina,
I am doing this for performance reason. Binding to xml stream or
dataset
causing lot of time to render page as my data is huge when I am using
tree view control. Any other solutions are welcome.
Thanks
Rao
"Marina" <so*****@nospam.com> wrote in message news:<Ol**************@TK2MSFTNGP09.phx.gbl>... Is it possible for the treeview control to take something else other then a file path? You really would want to avoid writing and deleting files for each user
"rao" <ja********@hotmail.com> wrote in message news:f2************************@posting.google.com ... Hi All,
I am generating temporary xml files to bind it to tree view control. A unique xml file is generated for each user. I generating these files Using streamwriter class. Later when I try to delete the file with File.Dlete in page unload event I gets an error File already in use by another process. When I examine process explorer aspnet_wp.exe is hold these files. Here is the code I am working on.. Any advise please.
Thanks in advance Rao
private void Page_UnLoad(object sender, System.EventArgs e) { try { if (File.Exists(Server.MapPath(xmlDocPath+ProjectsDoc ))) { ProjectTree.Dispose(); File.Delete(Server.MapPath(xmlDocPath+ProjectsDoc) ); }
} catch(Exception ex) {SetErrorMessage(ex.Message.ToString(),true); } }
private void InitializeTreeView() { //Add data to treeview based on the projectXML stored procedure //ProjectTree.TreeNodeSrc= DataRetrieval.formatXMLforTree("eacollin.ProjectXM L");
ProjectsDoc=DataRetrieval.PrepareProjectsXMLdoc("e acollin.ProjectXML"); ProjectTree.TreeNodeSrc= Server.MapPath(xmlDocPath+ProjectsDoc); ProjectTree.DefaultStyle.CssText="color: black;font-family: verdana;font-size: 8pt;"; ProjectTree.DataBind(); ProjectTree.Dispose(); }
private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); this.Unload+=new System.EventHandler(this.Page_UnLoad); //ProjectTree.Unload+=new System.EventHandler(this.DeleteXmlFiles);
} public static string PrepareProjectsXMLdoc(string SPname) { // added by rao 8/27/2004 // added projects cache to avoid round trip to sql server, and // additional processing involved in process returned xml from // stored procedure string strXML; strXML=""; DataSet ds=new DataSet(); string OutFileName=""; System.IO.StringWriter strWriter = new StringWriter(); try {
if(System.Web.HttpContext.Current.Cache["Projects"]==null) {
ds = SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings[ASPNET.StarterKit .TimeTracker.Web.Global.CfgKeyConnString], SPname);
strXML = ""; ds.WriteXml(strWriter); strXML = strWriter.ToString();
//get rid of the text version of < and > tags strXML = Regex.Replace(strXML, "<", "<"); strXML = Regex.Replace(strXML, ">", ">");
//get ride of the XML headers string search = @"</XML_F52E2B61-18A1-11d1-B105-00805F49916B>\s*</Table>\s*<Table>\s*<XML_F5 2E2B61-18A1-11d1-B105-00805F49916B>"; strXML = Regex.Replace(strXML,search,"");
//Get rid of apostrophes which do not show up properly on the webpage strXML = Regex.Replace(strXML,"&apos;","'");
//find the part of the xml that starts and ends with TREENODES int firstoccurance = strXML.IndexOf("TREENODES"); int secondoccurance = strXML.IndexOf("TREENODES",firstoccurance+1); int delta = secondoccurance - firstoccurance; strXML = strXML.Substring(firstoccurance,delta); strXML = "<" + strXML + "TREENODES>"; ds.Dispose();
// generate uniqe filename for each user lock(System.Web.HttpContext.Current.Cache) {
System.Web.HttpContext.Current.Cache.Insert("Proje cts",strXML,null, DateTime.Now.AddHours(HoursLeft),Cache.NoSlidingEx piration); }
} else { strXML =(string)System.Web.HttpContext.Current.Cache["Projects"];
} string NewGuid = System.Guid.NewGuid().ToString(); OutFileName=NewGuid+"_Projects.xml";
using(StreamWriter wr = new StreamWriter(System.Web.HttpContext.Current.Server .MapPath(xmlDocPath+OutFil eName))) { wr.Write(strXML); }
strWriter.Close();
//return OutFileName; } catch(Exception ex) { System.Web.HttpContext.Current.Response.Write(ex.M essage); } return OutFileName; }
Rao,
Did you ever find a way around this? I am having the same problem and
have noticed that the file gets locked when I close my browser with the
treeview open. Thanks,
drippy
rao wrote: Hi Marina,
I am doing this for performance reason. Binding to xml stream or dataset causing lot of time to render page as my data is huge when I am using tree view control. Any other solutions are welcome.
Thanks Rao
"Marina" <so*****@nospam.com> wrote in message
news:<Ol**************@TK2MSFTNGP09.phx.gbl>... Is it possible for the treeview control to take something else
other then a file path? You really would want to avoid writing and deleting
files for each user
"rao" <ja********@hotmail.com> wrote in message news:f2************************@posting.google.com ... Hi All,
I am generating temporary xml files to bind it to tree view
control. A unique xml file is generated for each user. I generating these
files Using streamwriter class. Later when I try to delete the file
with File.Dlete in page unload event I gets an error File already in
use by another process. When I examine process explorer aspnet_wp.exe is
hold these files. Here is the code I am working on.. Any advise please.
Thanks in advance Rao
private void Page_UnLoad(object sender, System.EventArgs e) { try { if (File.Exists(Server.MapPath(xmlDocPath+ProjectsDoc ))) { ProjectTree.Dispose(); File.Delete(Server.MapPath(xmlDocPath+ProjectsDoc) ); }
} catch(Exception ex) {SetErrorMessage(ex.Message.ToString(),true); } }
private void InitializeTreeView() { //Add data to treeview based on the projectXML stored procedure //ProjectTree.TreeNodeSrc= DataRetrieval.formatXMLforTree("eacollin.ProjectXM L");
ProjectsDoc=DataRetrieval.PrepareProjectsXMLdoc("e acollin.ProjectXML"); ProjectTree.TreeNodeSrc= Server.MapPath(xmlDocPath+ProjectsDoc); ProjectTree.DefaultStyle.CssText="color: black;font-family: verdana;font-size: 8pt;"; ProjectTree.DataBind(); ProjectTree.Dispose(); }
private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); this.Unload+=new System.EventHandler(this.Page_UnLoad); //ProjectTree.Unload+=new
System.EventHandler(this.DeleteXmlFiles); } public static string PrepareProjectsXMLdoc(string SPname) { // added by rao 8/27/2004 // added projects cache to avoid round trip to sql server, and // additional processing involved in process returned xml from // stored procedure string strXML; strXML=""; DataSet ds=new DataSet(); string OutFileName=""; System.IO.StringWriter strWriter = new StringWriter(); try {
if(System.Web.HttpContext.Current.Cache["Projects"]==null) {
ds =
SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings[ASPNET.StarterKit .TimeTracker.Web.Global.CfgKeyConnString], SPname);
strXML = ""; ds.WriteXml(strWriter); strXML = strWriter.ToString();
//get rid of the text version of < and > tags strXML = Regex.Replace(strXML, "<", "<"); strXML = Regex.Replace(strXML, ">", ">");
//get ride of the XML headers string search =
@"</XML_F52E2B61-18A1-11d1-B105-00805F49916B>\s*</Table>\s*<Table>\s*<XML_F5 2E2B61-18A1-11d1-B105-00805F49916B>"; strXML = Regex.Replace(strXML,search,"");
//Get rid of apostrophes which do not show up properly on the webpage strXML = Regex.Replace(strXML,"&apos;","'");
//find the part of the xml that starts and ends with TREENODES int firstoccurance = strXML.IndexOf("TREENODES"); int secondoccurance = strXML.IndexOf("TREENODES",firstoccurance+1); int delta = secondoccurance - firstoccurance; strXML = strXML.Substring(firstoccurance,delta); strXML = "<" + strXML + "TREENODES>"; ds.Dispose();
// generate uniqe filename for each user lock(System.Web.HttpContext.Current.Cache) {
System.Web.HttpContext.Current.Cache.Insert("Proje cts",strXML,null, DateTime.Now.AddHours(HoursLeft),Cache.NoSlidingEx piration); }
} else { strXML =(string)System.Web.HttpContext.Current.Cache["Projects"];
} string NewGuid = System.Guid.NewGuid().ToString(); OutFileName=NewGuid+"_Projects.xml";
using(StreamWriter wr = new
StreamWriter(System.Web.HttpContext.Current.Server .MapPath(xmlDocPath+OutFil eName))) { wr.Write(strXML); }
strWriter.Close();
//return OutFileName; } catch(Exception ex) { System.Web.HttpContext.Current.Response.Write(ex.M essage); } return OutFileName; } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Top Hat |
last post by:
Greetings!
My application uses several files that contain constants, error code,
etc that are located in a directory call /bin. At times when I am
testing the application in "debug" mode, the...
|
by: Trevor Andrew |
last post by:
Hi There,
I have a small ASP.NET application under development. I am using VS.NET 2002
(2003 upgrade is on the way) with .NET Framework 1.1. It is hosted on a web
hosting service in the US. I am...
|
by: Abhishek Srivastava |
last post by:
Hello All,
In IIS 6.0 We have a concept of worker processes and application pools.
As I understand it, we can have multiple worker process per appliction
pool. Each worker process is dedicated...
|
by: Richard Myers |
last post by:
Hello
Im sure many of you have seen this error message before:
For us its the third time this year. This error occurs seemingly at random.
I have no idea what causes it too happen. None....
|
by: alex |
last post by:
I can map all files (.*) to asp.net worker process. But that is a
perfomance hit and default documents are no longer working.
How do I map "NO FILE" to asp.net worker?
Like if I have an url : ...
|
by: J-T |
last post by:
I guess I'm a litte bit confused about app pool and worker process.
In IIS 6.0 We have a concept of worker processes and application pools. As I
understand it, we can have multiple worker process...
|
by: Gregory Gadow |
last post by:
Still working on this project.
What I have working: I have a service that uses FileSystemWatcher on an
"in box" folder. When a text file appears in the in-box, it copies the
file to a work...
|
by: George |
last post by:
Hi,
I am re-writing part of my application using C#. This application starts
another process which execute a "legacy" program. This legacy program writes
to a log file and before it ends, it...
|
by: sjoshi |
last post by:
I'm able to use the Bacground Worker class to execute task and pain the
UI. However I want to be able to execute n tasks in order, say n1, then
n2 if there were no errors during n1, n3 so on.
...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |