Skip to content

Problem in axwebbrowser.navigate

shantanu

Asked Dec 14, 2006, 5:51 AM EST2 answers
Share
LinkedInX
Hi , I am using VS .NET 2003 on XP SP2. when I am using the axwebbrowser.navigate() in my code, its actually locking the file which I supply to it as URL. I am pasting the code below: ################################################################################### public string Xml { set { StreamWriter writer; object missing = System.Reflection.Missing.Value; missing = null; _fileName="C:\\XMLFiles\\"+Guid.NewGuid() + ".xml"; using (writer = new StreamWriter(_fileName, false)) { writer.Write(value); } _ctrlWeb.Navigate( _fileName, ref missing, ref missing, ref missing, ref missing ); if (_previousFileName.Length > 0) { File.Delete(_previousFileName); } _previousFileName=_fileName; } } ################################################################################### I think that most probably the navigate function is not going to the new url & hence locking the older URL, hence I am getting an exception of "File already in Use by another process" in the delete function. I really do not know how to rectify this. Would really appreciate any inputs in resolving this.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Firstly it's really hard to read your code as it's all on one line.

    It doesn't look like you're closing the StreamWriter anywhere.

    You should open the StreamWriter in a try block and then close it in a finally block.
    0
  • 0
    Hi , Thanks for response, I am pasting the code again.. Actually since I am using the streamwriter in using clause, I thought I did not need to close it... anyways I did tried by closing it ... but again the same results, infact if I remove the web.navigate(...), I do not face this problem, Hence I guess the problem is mainly in .navigate locking the file.. Would really appreciate if can get some help.. ################################################################################### public string Xml { set { StreamWriter writer; object missing = System.Reflection.Missing.Value; missing = null; _fileName="C:\\XMLFiles\\"+Guid.NewGuid() + ".xml"; using (writer = new StreamWriter(_fileName, false)) { writer.Write(value); } _ctrlWeb.Navigate( _fileName, ref missing, ref missing, ref missing, ref missing ); if (_previousFileName.Length > 0) { File.Delete(_previousFileName); } _previousFileName=_fileName; } } ###################################################################################
    0