javascript FolderExists 判斷資料夾是否存在 練習
=========說明、註記=============================
MSDN路徑1030325 :
http://msdn.microsoft.com/en-us/library/5xc78d8d(v=vs.84).aspx
=========MSDN 的 CODE==========================
JScript
function ReportFolderStatus(fldr)
{
var fso, s = fldr;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FolderExists(fldr))
s += " exists.";
else
s += " doesn't exist.";
return(s);
}
=========HTML上 的 CODE==========================
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function copyfolder() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFolder("\\\\192.168.0.1\\測試資料\\tempjpg", "C:\\Documents and Settings\\All Users\\Documents\\tempjpg");
alert("COPY OK");
}
function getfolder() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FolderExists("\\\\192.168.0.1\\測試資料\\tempjpg"))
{
alert("網路資料夾-存在")
if (fso.FolderExists("C:\\Documents and Settings\\All Users\\Documents\\tempjpg")) {
alert("本機資料夾夾-存在")
}
else
{ alert("本機資料夾-不存在") }
}
else {
alert("網路資料夾-不存在")
}
}
</script>
</head>
<body>
<input id="Button1" type="button" value="copyfolder" onclick="copyfolder()" /> |
<input id="Button2" type="button" value="getfolder" onclick="getfolder()"/>
</body>
</html>
沒有留言:
張貼留言