Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / JFileChooser и Мои документы / 10 сообщений из 10, страница 1 из 1
24.02.2005, 14:43
    #32931346
GMax
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
JFileChooser и Мои документы
У класса JFileChooser есть метод setCurrentDirectory, который устанавливает текущий каталог для выбора файла.
Требуется указать папку Мои документы текущего пользователя Windows XP/2000.
Как получить путь к ней?
...
Рейтинг: 0 / 0
25.02.2005, 10:15
    #32932657
foo
foo
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
JFileChooser и Мои документы
Мои документы располагаются по адресу:

"<drive>:/Documents and Settings/<user_name>/My Documents"

Таким образом Вам надо узнать диск на котором стоит система и имя пользователя. Диск можно узнать из переменной окружения WINDIR получив ее с помощью System.getenv(..);
Таким же образом можно убедиться что программы запущена под Windows....

А вот "правильных" методов получить имя пользователя я не знаю..
Могу только посоветовать "неправильный" метод: посмотреть переменную окружения TEMP... тогда можно будет WINDIR не дергать.. но это плохой способ т.к TEMP можно легко изменить...
...
Рейтинг: 0 / 0
25.02.2005, 10:20
    #32932677
Andrey Spirin
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
JFileChooser и Мои документы
для имени пользователя можно попробывать изспользовать USERPROFILE переменную из переменных среды окружения (Env)
...
Рейтинг: 0 / 0
25.02.2005, 10:34
    #32932729
Ося
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
JFileChooser и Мои документы
че то не понял, а это уже не катит:


Код: plaintext
1.
2.
Properties sysProperties = System.getProperties();
String user = (String) sysProperties.get("user.home");
...
Рейтинг: 0 / 0
25.02.2005, 11:19
    #32932893
GMax
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
JFileChooser и Мои документы
Всем сенкью вери матч.

Код: plaintext
1.
Properties sysProperties = System.getProperties();
String user = (String) sysProperties.get("user.home");

То что нужно.
...
Рейтинг: 0 / 0
25.02.2005, 11:36
    #32932946
javadoc
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
JFileChooser и Мои документы
GMaxУ класса JFileChooser есть метод setCurrentDirectory, который устанавливает текущий каталог для выбора файла.
Требуется указать папку Мои документы текущего пользователя Windows XP/2000.
Как получить путь к ней?

javadoc
setCurrentDirectory
--
public void setCurrentDirectory(File dir)

Sets the current directory. Passing in null sets the file chooser to point to the
user's default directory. This default depends on the operating system. It is typically
the "My Documents" folder on Windows, and the user's home directory on Unix. If the
file passed in as currentDirectory is not a directory, the parent of the file will be used
as the currentDirectory. If the parent is not traversable, then it will walk up the parent
tree until it finds a traversable directory, or hits the root of the file system.
...
Рейтинг: 0 / 0
25.02.2005, 11:46
    #32932997
GMax
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
JFileChooser и Мои документы
javadoc
setCurrentDirectory
--
public void setCurrentDirectory(File dir)

Sets the current directory. Passing in null sets the file chooser to point to the
user's default directory. This default depends on the operating system. It is typically
the "My Documents" folder on Windows, and the user's home directory on Unix. If the
file passed in as currentDirectory is not a directory, the parent of the file will be used
as the currentDirectory. If the parent is not traversable, then it will walk up the parent
tree until it finds a traversable directory, or hits the root of the file system.

Мне стало стыдно...
...
Рейтинг: 0 / 0
25.02.2005, 11:59
    #32933058
JFileChooser и Мои документы
GMax javadoc
setCurrentDirectory
--
public void setCurrentDirectory(File dir)

Sets the current directory. Passing in null sets the file chooser to point to the
user's default directory. This default depends on the operating system. It is typically
the "My Documents" folder on Windows, and the user's home directory on Unix. If the
file passed in as currentDirectory is not a directory, the parent of the file will be used
as the currentDirectory. If the parent is not traversable, then it will walk up the parent
tree until it finds a traversable directory, or hits the root of the file system.

Мне стало стыдно...

А мы вообще! Мы вообще не знаем куда нам скрыться!
...
Рейтинг: 0 / 0
25.02.2005, 14:38
    #32933650
foo
foo
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
JFileChooser и Мои документы
GMaxМне стало стыдно...

мне тоже :(
...
Рейтинг: 0 / 0
25.02.2005, 14:44
    #32933669
JFileChooser и Мои документы
foo GMaxМне стало стыдно...

мне тоже :(
спасибо :)
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / JFileChooser и Мои документы / 10 сообщений из 10, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]