public class WinFileSystem
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
createShellLink(java.io.File file,
java.io.File shortcutTo,
java.io.File iconFile)
Creates a shell link.
|
static boolean |
createShellLink(java.io.File file,
java.io.File shortcutTo,
java.io.File iconFile,
java.lang.String arguments)
Creates a shell link.
|
static boolean |
createShellLink(java.io.File file,
java.io.File shortcutTo,
java.io.File iconFile,
java.lang.String arguments,
java.lang.String description)
Creates a shell link.
|
static boolean |
createShellLink(java.io.File file,
java.io.File shortcutTo,
java.io.File iconFile,
java.lang.String arguments,
java.lang.String description,
java.io.File startIn)
Creates a shell link.
|
static boolean |
createShellLink(java.io.File file,
java.io.File shortcutTo,
java.io.File iconFile,
java.lang.String arguments,
java.lang.String description,
java.io.File startIn,
ShowCommand showCommand)
Creates a shell link.
|
static void |
createStartMenuEntry(java.lang.String programGroupName,
java.lang.String entryName,
java.io.File destination,
boolean allUsers,
java.io.File icon)
Creates a start menu entry.
|
static void |
createStartMenuEntry(java.lang.String programGroupName,
java.lang.String entryName,
java.io.File destination,
boolean allUsers,
java.io.File icon,
java.lang.String arguments)
Creates a start menu entry.
|
static void |
createStartMenuEntry(java.lang.String programGroupName,
java.lang.String entryName,
java.io.File destination,
boolean allUsers,
java.io.File icon,
java.lang.String arguments,
boolean runAsAdministrator)
Creates a start menu entry.
|
static java.io.File |
getCommonFilesDirectory()
Returns a folder for components that are shared across applications.
|
static DriveType |
getDriveType(java.io.File file)
Tests on what kind of drive the given file is (or would be) located.
|
static java.io.File |
getProgramDataDirectory()
Returns the program data directory where applications can save data that is not specific to particular users.
|
static java.io.File |
getProgramFilesDirectory()
Returns the program files directory of the current Windows installation.
|
static java.io.File |
getSpecialFolder(SpecialFolder folderType,
boolean allUsers)
Returns Windows-specific directories like the start menu or the
desktop.
|
static java.io.File |
getSystemDirectory()
Returns the system directory.
|
static java.io.File |
getWindowsDirectory()
Returns the Windows directory.
|
static boolean |
moveWithDelayUntilReboot(java.io.File source,
java.io.File destination)
Calls the win32 API function MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT.
|
public static java.io.File getSpecialFolder(SpecialFolder folderType, boolean allUsers)
folderType
- specifies the requested folder type.allUsers
- if this parameter is true
and if the current user is in the
Administrators group, the method returns the requested folder for all users.
Otherwise it returns the folder for the current user.public static java.io.File getProgramFilesDirectory()
C:\Program Files
.public static java.io.File getCommonFilesDirectory()
C:\Users\<i>user name</i>\AppData\Roaming
.public static java.io.File getProgramDataDirectory()
C:\ProgramData
.public static java.io.File getWindowsDirectory()
C:\Windows
.public static java.io.File getSystemDirectory()
C:\Windows\system32
public static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile)
lnk
to pif
,
if you are linking to a DOS executable or a batch file.
This as the same as calling createShellLink(file, shortcutTo, iconFile, null, null)
file
- the shell link that should be created including the lnk
suffix.shortcutTo
- the file it should link to.iconFile
- an optional icon file. If null
is passed, the default icon of the
shortcutTo
target will be used.createShellLink(File, File, File, String)
public static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments)
lnk
to pif
,
if you are linking to a DOS executable or a batch file.
This as the same as calling createShellLink(file, shortcutTo, iconFile, arguments, null)
file
- the shell link that should be created including the lnk
suffix.shortcutTo
- the file it should link to.iconFile
- an optional icon file. If null
is passed, the default icon of the
shortcutTo
target will be used.arguments
- the arguments passed to the target.public static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description)
lnk
to pif
,
if you are linking to a DOS executable or a batch file.file
- the shell link that should be created including the lnk
suffix.shortcutTo
- the file it should link to.iconFile
- an optional icon file. If null
is passed, the default icon of the
shortcutTo
target will be used.arguments
- the arguments passed to the target.description
- the description used in the tooltippublic static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description, java.io.File startIn)
lnk
to pif
,
if you are linking to a DOS executable or a batch file.file
- the shell link that should be created including the lnk
suffix.shortcutTo
- the file it should link to.iconFile
- an optional icon file. If null
is passed, the default icon of the
shortcutTo
target will be used.arguments
- the arguments passed to the target.description
- the description used in the tooltipstartIn
- the working directory for the executablepublic static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description, java.io.File startIn, ShowCommand showCommand)
lnk
to pif
,
if you are linking to a DOS executable or a batch file.file
- the shell link that should be created including the lnk
suffix.shortcutTo
- the file it should link to.iconFile
- an optional icon file. If null
is passed, the default icon of the
shortcutTo
target will be used.arguments
- the arguments passed to the target.description
- the description used in the tooltipstartIn
- the working directory for the executableshowCommand
- the window show commandpublic static void createStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon) throws java.io.IOException
programGroupName
- the name of the program group where the entry should be createdentryName
- the name of the menu entry. You can create subfolders with backslashes.destination
- the file that should be linked toallUsers
- whether the entry should be created for all users or noticon
- an optional icon file. If null
is passed, the default icon of the
destination
target will be used.java.io.IOException
- if the start menu entry could not be createdpublic static void createStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon, java.lang.String arguments) throws java.io.IOException
programGroupName
- the name of the program group where the entry should be createdentryName
- the name of the menu entry. You can create subfolders with backslashes.destination
- the file that should be linked toallUsers
- whether the entry should be created for all users or noticon
- an optional icon file. If null
is passed, the default icon of the
destination
target will be used.arguments
- optional arguments given to the destination. Can be null
java.io.IOException
- if the start menu entry could not be createdpublic static void createStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon, java.lang.String arguments, boolean runAsAdministrator) throws java.io.IOException
programGroupName
- the name of the program group where the entry should be createdentryName
- the name of the menu entry. You can create subfolders with backslashes.destination
- the file that should be linked toallUsers
- whether the entry should be created for all users or noticon
- an optional icon file. If null
is passed, the default icon of the
destination
target will be used.arguments
- optional arguments given to the destination. Can be null
runAsAdministrator
- whether the entry should be run as administratorjava.io.IOException
- if the start menu entry could not be createdpublic static boolean moveWithDelayUntilReboot(java.io.File source, java.io.File destination)
source
- the source file. Must be on the same drive as the destination file.destination
- the destination file. If empty, the source file will be deleted.