Home  >  Article  >  Web Front-end  >  Summary of javascript operation file implementation methods_javascript skills

Summary of javascript operation file implementation methods_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:50:47797browse

You can create files on the visitor's hard drive through the browser, because I first tried it and it worked. If you don't believe me, COPY the following code into an HTML file and run it again!

Copy code The code is as follows:



Did you find that the Autoexec.bat file on your C drive is missing? Haha, actually when that file is run, IE will remind you that the ActiveX control you are currently using is unsafe and ask you whether to run it, but since you are as eager as me to try out the effect, you will press [OK] without hesitation. .... In fact, this is implemented using FileSystemObject. If you want to know more detailed usage and examples, click here to download the Chinese documentation of JScript or buy a copy of <> You can also take a look at the examples compiled by Wuyou Script for everyone to learn. Let us first take a look at what attributes and functions are available, and then we will make some small examples of some functions
Method or attribute description
BuildPath()
Generate a file path
Copy code The code is as follows:

CopyFile() Copy file
CopyFolder() Copy a directory
CreateFolder() Create a new directory
CreateTextFile() Generate a file
DeleteFile() Delete a file
DeleteFolder() Delete a directory
DriveExists() Check whether the drive letter exists
Drives Return the set of drive letters
FileExists() Check whether the file exists
FolderExists Check whether a directory exists
GetAbsolutePathName() Get the absolute path of a file
GetBaseName( ) Get the file name
GetDrive() Get the drive letter name
GetDriveName() Get the drive letter name
GetExtensionName() Get the file suffix
GetFile() Generate the file object
GetFileName() Get File name
GetFolder() Get the directory object
GetParentFolderName Get the parent directory name of the file or directory
GetSpecialFolder() Get the special directory name
GetTempName() Generate a temporary file object
MoveFile( ) Move files
MoveFolder() Move directories
OpenTextFile()

Open a file stream instance description BuildPath(path, file name) //This method will add to the given path Upload the file and automatically add delimiters
Copy the code The code is as follows:



CopyFile(source File, target file, overwrite) //Copy the source file to the target file. When the overwrite value is true, the file will be overwritten if the target file exists
Copy code The code is as follows:



CopyFolder(object directory, target directory, overwrite) //Copy the object directory to the target directory. When overwrite is true, the file will be overwritten if the target directory exists
Copy code The code is as follows:



CreateFolder(directory name) //Create a new directory
Copy the code The code is as follows:



CreateTextFile(file name, overwrite) //Create a new file. If the file already exists, you need to set the overwrite value to true
Copy code The code is as follows :



DeleteFile(file name, read-only?) //Delete a file. If the file attribute is read-only, you need to set the read-only value to true
Copy code The code is as follows:



DriveExists(drive letter) //Check whether a drive exists, if it exists, it will return true, if it does not exist, it will return...
Copy code The code is as follows:



FileExists(file name) //Check whether a file exists, and return true if it exists , return if it does not exist...
Copy code The code is as follows:



FolderExists(directory name) //Check whether a directory exists, if it exists Returns true, returns if it does not exist...
Copy code The code is as follows:



GetBaseName(file object) //Return to file The file name of the object
Copy code The code is as follows:



GetExtensionName (file object) //The suffix of the file
Copy code The code is as follows:



GetParentFolderName (file object) //Get the parent directory name
Copy code The code is as follows:



GetSpecialFolder(directory code) //Get the paths to some special directories in the system. There are three directory codes: 0: Directory where Windows is installed 1: System file directory 2: Temporary file directory
Copy code The code is as follows:



GetTempName( ) //Generate a random temporary file object, starting with rad followed by some random numbers, just like some software will generate *.tmp during installation
Copy Code The code is as follows:

To Be Continue! There are still a few attributes that I haven’t written examples for. I will give them later. Do you think it will happen every time? Are you having trouble running? Or..., wondering how to run without asking? (Don’t use scripts to damage other people’s systems!)
Use JavaScript to create shortcuts to the file system
Copy code The code is as follows:




用JavaScript创建快捷方式










Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn