Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Scripting
Script Runtime
FileSystemObject
 GetSpecialFolder Method
Collapse All/Expand All Collapse All
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
Scripting Runtime Library
GetSpecialFolder Method

Returns the special folder object specified.

object.GetSpecialFolder(folderspec) 
object

Required. Always the name of a FileSystemObject.

folderspec

Required. The name of the special folder to be returned. Can be any of the constants shown in the Settings section.

The folderspec argument can have any of the following values:

Constant

Value

Description

WindowsFolder

0

The Windows folder contains files installed by the Windows operating system.

SystemFolder

1

The System folder contains libraries, fonts, and device drivers.

TemporaryFolder

2

The Temp folder is used to store temporary files. Its path is found in the TMP environment variable.

The following example illustrates the use of the GetSpecialFolder method.

JScript
var fso, tempfile;
fso = new ActiveXObject("Scripting.FileSystemObject");

function CreateTempFile()
{
   var tfolder, tfile, tname, fname, TemporaryFolder = 2;
   tfolder = fso.GetSpecialFolder(TemporaryFolder);
   tname = fso.GetTempName();
   tfile = tfolder.CreateTextFile(tname);
   return(tfile);
}
tempfile = CreateTempFile();
tempfile.writeline("Hello World");
tempfile.close();

VBScript
Dim fso, tempfile
Set fso = CreateObject("Scripting.FileSystemObject")

Function CreateTempFile 
   Dim tfolder, tname, tfile
   Const TemporaryFolder = 2
   Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
   tname = fso.GetTempName   
   Set tfile = tfolder.CreateTextFile(tname)
   Set CreateTempFile = tfile
End Function

Set tempfile = CreateTempFile
tempfile.WriteLine "Hello World"
tempfile.Close

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker