FIX: WinIOException Occurs when Calling dumpHTML or dumpDHTML
ID: Q195173
|
The information in this article applies to:
-
Microsoft Visual J++, version 6.0
SYMPTOMS
When calling DhDocument.dumpHTML() or DhDocument.dumpDHTML() the following
exception might occur:
com.ms.wfc.io.WinIOException: The system cannot find the path specified
(D:/Visual%20Studio%20Projects/Dump%20Test/__dump.txt)
at com/ms/wfc/io/File.<init> (File.java)
at com/ms/wfc/io/File.create (File.java)
at com/ms/wfc/html/DhDocument.writeHTML (DhDocument.java)
at com/ms/wfc/html/DhDocument.dumpHTML (DhDocument.java)
at com/ms/wfc/html/DhDocument.dumpDHTML (DhDocument.java)
CAUSE
The dumpHTML method does not translate URLs with "%20" into a space when
determining the file name to create.
NOTE: Other characters besides "%20" in the URL might also not be translated properly.
void dumpDHTML(Object, Event) has been deprecated by the author
of 'com.ms.wfc.html.DhDocument' and should not be used.
RESOLUTION
Do one of the following to work around this issue:
- Make sure your files are stored in a directory structure containing only numbers and letters.
- Write your own method to show the HTML and make sure the file it creates is in a directory structure containing only numbers and letters.
- Write your own method that loads a blank page and then dynamically adds data to the page.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
This bug was corrected in Visual Studio 6.0 Service Pack 3.
For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:
Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
MORE INFORMATION
Steps to Reproduce Behavior
- In Visual J++, select New Project from the File menu.
- In the New Project dialog box, click the New tab.
- In the Visual J++ Projects tree, click Web Pages.
- Click Code-Behind HTML.
- Click Open to create the project.
- Modify Class1.java as follows:
import com.ms.wfc.html.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
public class Class1 extends DhDocument
{
public Class1()
{
initForm();
}
private void initForm()
{
}
protected void onDocumentLoad(Object sender, Event e)
{
DhButton button=new DhButton("button");
add(button);
this.dumpDHTML(null,null);
// Workaround1: Uncomment the next line and comment the above line.
// You must have a "c:\temp" directory or change the directory below.
// showHTML("c:\\temp\\");
// Workaround2: Uncomment the next line and comment the above line.
// You must have a blank.htm in the current directory.
// showHTML();
}
public void showHTML(String directory) {
String filename=directory+"__dump.txt";
addText(filename);
com.ms.wfc.io.File outputFile =
com.ms.wfc.io.File.create(filename);
writeHTML(outputFile);
outputFile.close();
getWindow().open(filename,"dump",null,false);
}
public void showHTML() {
// You must have a "blank.htm" in the current directory
DhWindow window=getWindow().open("blank.htm","dump",null,false);
DhDocument document=window.getDocument();
String x=getHTML();
document.add(new DhRawHTML(toHTMLViewable(getHTML())));
}
static String toHTMLViewable(String text) {
// indexOf() returns -1 if not found:
if (text.indexOf('<')+text.indexOf('>')+text.indexOf('&')==-3)
return text;
StringBuffer buffer=new StringBuffer(text);
int index=0;
String amp="amp;";
String less="lt;";
String greater="gt;";
while (buffer.length()>index) {
if (buffer.charAt(index)=='&') {
buffer.insert(index+1,amp);
} else if (buffer.charAt(index)=='<') {
buffer.setCharAt(index,'&');
buffer.insert(index+1,less);
} else if (buffer.charAt(index)=='>') {
buffer.setCharAt(index,'&');
buffer.insert(index+1,greater);
}
index++;
}
return buffer.toString();
}
}
- Modify Page1.html as follows:
<HTML>
<BODY>
<hr>
<OBJECT classid="java:com.ms.wfc.html.DhModule"
height=0 width=0 ... VIEWASTEXT>
<PARAM NAME=__CODECLASS VALUE=Class1>
<PARAM NAME=CABBASE VALUE=Project1.CAB>
</OBJECT>
<!-- Insert HTML here -->
</BODY>
</HTML>
- Run the project.
RESULT: A WinIOException error occurs. To work around the problem, create an empty Blank.htm file and make sure a C:\Temp directory exists. Comment the call to dumpHTML(). Uncomment the first workaround line if you want to create an output file in the C:\Temp directory and display the results. Uncomment the second workaround if you want to dynamically display the results without writing to the local drive.
REFERENCES
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java,
please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/
http://support.microsoft.com/support/java/
© Microsoft Corporation 1998, All Rights Reserved.
Contributions by Derek Jamison, Microsoft Corporation
Additional query words:
Keywords : kbservicepack kbhtml kbDHTML kbJava kbVJ600bug kbWFC kbVS600sp2 kbVS600SP1 kbVS600sp3fix
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbbug