js能做一个选择本地文件夹目录单位东西吗,选好了文件之后返回文件路径来...
发布网友
发布时间:2023-12-20 09:16
我来回答
共2个回答
热心网友
时间:2024-07-22 03:36
在Windows平台上, js可以调用很多Windows提供的ActivexObject,本文就使用js来实现文档处理, 和使用js编写ActiveX做一个简单介绍.
复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>
<script type="text/javascript">
function readFolder(){
var filePath = "d:\\test\\";
var fso = new ActiveXObject("Scripting.FileSystemObject"); //加载控件
var f = fso.GetFolder(filePath);
var underFiles = new Enumerator(f.files); //文件夹下文件
for (;!underFiles.atEnd();underFiles.moveNext()){
var fn = "" + underFiles.item();
//alert(fn);
var content = readFile(fn,fso);
alert(content);
}
}
function readFile(path,fso){
var f1 = fso.GetFile(path);
var fh = fso.OpenTextFile(f1, 1/*reading*/);
var content = '';
while ( !fh.AtEndOfStream ) {
content += fh.ReadLine();
}
fh.close()
return content;
}
热心网友
时间:2024-07-22 03:37
<html>
<head>
<title> New Document </title>
</head>
<script type="text/javascript">
function readFolder(){
var filePath = "d:\\test\\";
var fso = new ActiveXObject("Scripting.FileSystemObject"); //加载控件
var f = fso.GetFolder(filePath);
var underFiles = new Enumerator(f.files); //文件夹下文件
for (;!underFiles.atEnd();underFiles.moveNext()){
var fn = "" + underFiles.item();
//alert(fn);
var content = readFile(fn,fso);
alert(content);
}
}
function readFile(path,fso){
var f1 = fso.GetFile(path);
var fh = fso.OpenTextFile(f1, 1/*reading*/);
var content = '';
while ( !fh.AtEndOfStream ) {
content += fh.ReadLine();
}
fh.close()
return content;
}
function writeExcel(){
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
ExcelSheet.Application.Visible