asp 创建文件与文件夹函数<br /> asp创建文件夹函数<br /> Function CreateFolder(FolderPath)<br /> ' On Error Resume Next<br /> Set Fso=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)<br /> Set F=Fso.CreateFolder(Server.MapPath(FolderPath))<br /> CreateFolder=F.Path<br /> Set F=Nothing<br /> Set Fso=Nothing<br /> ' Select Case Err<br /> ' Case 424 Response.Write(&quot;方卡错误提示:创建&quot;&amp;FolderPath&amp;&quot;文件夹时,路径未找到或者该目录没有写入权限!&quot;)<br /> ' End Select<br /> End Function<br /> <br /> <br /> asp创建文件函数<br /> Function CreateFile(FilePath,FileContent)<br /> ' On Error Resume Next<br /> Dim Temps<br /> Temps=&quot;&quot;<br /> TempArr=Split(FilePath,&quot;/&quot;)<br /> For i=0 to UBound(TempArr)-1<br /> If Temps=&quot;&quot; Then<br /> Temps=TempArr(i)<br /> Else<br /> Temps=Temps&amp;&quot;/&quot;&amp;TempArr(i)<br /> End If<br /> If IsFolder(Temps)=False Then<br /> Call CreateFolder(Temps)<br /> End If<br /> Next<br /> Set objAdoStream = Server.CreateObject(&quot;Adodb.Stream&quot;)<br /> objAdoStream.Type = 2<br /> objAdoStream.Charset = &quot;UTF-8&quot; <br /> objAdoStream.Open<br /> objAdoStream.WriteText = FileContent<br /> objAdoStream.SaveToFile Server.MapPath(FilePath),2<br /> objAdoStream.Close()<br /> Set objAdoStream = Nothing<br /> ' Select Case Err <br /> ' Case 424 Response.Write(&quot;方卡错误提示:创建&quot;&amp;FilePath&amp;&quot;文件时,路径未找到或者该目录没有写入权限!&quot;)<br /> ' End Select<br /> End Function
返回顶部 留言