在本节中,将学习如何修改 ExportSetup() 方法,从而为 HTML32 和 HTML40 导出格式创建文件夹。
修改 ExportSetup() 方法
在类的顶部,添加以下类声明:
Private exportPathHTML32 As String Private exportPathHTML40 As Stringprivate string exportPathHTML32; private string exportPathHTML40;在 ExportSetup() 方法中,将 exportPathHTML32 和 exportPathHTML40 字符串变量实例化为硬盘的根目录。
``` vb
exportPathHTML32 = "C:\Exported\HTML32\"
exportPathHTML40 = "C:\Exported\HTML40\"
```
``` csharp
exportPathHTML32 = "C:\\Exported\\HTML32\\";
exportPathHTML40 = "C:\\Exported\\HTML40\\";
```
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />注意</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>如果要把文件夹放在 Web 服务器的 Web 目录中,请用 Request.PhysicalApplicationPath 属性给文件夹名加上前缀。</p></td>
</tr>
</tbody>
</table>
创建条件块,测试 exportPathHTML32 字符串中的目录是否已经存在。
If Not System.IO.Directory.Exists(exportPathHTML32) Then End Ifif (!System.IO.Directory.Exists(exportPathHTML32)) { }在该条件块中,调用 System.IO.Directory 的 CreateDirectory() 方法以创建 exportPathHTML32 字符串中的目录。
``` vb
System.IO.Directory.CreateDirectory(exportPathHTML32)
```
``` csharp
System.IO.Directory.CreateDirectory(exportPathHTML32);
```
创建条件块,测试 exportPathHTML40 字符串中的目录是否已经存在。
If Not System.IO.Directory.Exists(exportPathHTML40) Then End Ifif (!System.IO.Directory.Exists(exportPathHTML40)) { }在该条件块中,调用 System.IO.Directory 的 CreateDirectory() 方法以创建 exportPathHTML40 字符串中的目录。
``` vb
System.IO.Directory.CreateDirectory(exportPathHTML40)
```
``` csharp
System.IO.Directory.CreateDirectory(exportPathHTML40);
```